<script src="Scripts/jquery-1.7.min.js" type="text/javascript"></script> <script> window.setInterval("Method()", 1000); Method = function () { var ff = parseFloat($("img").css("opacity")).toFixed(1); // alert(ff); if (ff == 0.6) $("img").fadeTo("slow", 1); else $("img").fadeTo("slow", 0.6); }; </script> <img border="0" src="Images/Bald.jpg" width="400" />
Saturday, December 10, 2011
Fading image using jquery FadeTo
Tuesday, December 6, 2011
Populate Select from ajax with jquery
<head> <script src="Scripts/jquery-1.7.min.js" type="text/javascript"></script> <script> $(document).ready(function () { $.ajax({ url: "Fetchdata.ashx", type: "GET", dataType : 'json', success: function (msg) { $("#ddlcity").get(0).options.length = 0; $("#ddlcity").get(0).options[0] = new Option("Select City", "-1"); $.each(msg, function (k, v) { //alert(v); $("#ddlcity").get(0).options[$("#ddlcity").get(0).options.length] = new Option(v.Name, v.ID); }); }, error: function (msg) { alert("Error !!!!"); } }); }); </script> </head> <body> <select id="ddlcity"></select> </body>
<%@ WebHandler Language="C#" Class="Fetchdata" %> using System; using System.Web; using System.Collections.Generic; public class Fetchdata : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; List Objcity = GetList(); System.Web.Script.Serialization.JavaScriptSerializer objJs = new System.Web.Script.Serialization.JavaScriptSerializer(); context.Response.Write( objJs.Serialize(Objcity)); } public bool IsReusable { get { return false; } } public List GetList() { List <Citydata> item = new List<Citydata>(); item.Add(new Citydata() { Name = "Delhi", Id = "1" }); item.Add(new Citydata() { Name = "Mumbai", Id = "2" }); item.Add(new Citydata() { Name = "Kolcatta", Id = "3" }); item.Add(new Citydata() { Name = "Chennai", Id = "4" }); item.Add(new Citydata() { Name = "Banglore", Id = "5" }); item.Add(new Citydata() { Name = "Agra", Id = "6" }); return item; } } public class Citydata { string _Name = string.Empty; public string Name { get { return _Name; } set { _Name = value; } } string _Id = string.Empty; public string Id { get { return _Id; } set { _Id = value; } } }
Tags
AJAX
,
Asp.net
,
C#
,
DropDownList
,
JavaScript
,
jquery
Subscribe to:
Posts
(
Atom
)