Tag: ajax

Detecting Mouse Movement with jQuery

Author: | Categories: Programming No Comments
Javascript / jQuery can help in capturing Mouse move, Scroll and Click events Option 1 – Capturing Mouse move along with Click and Scroll var timeout = null; $(document).on('mousemove click scroll', function() { clearTimeout(timeout); timeout = setTimeout(function() { console.log('Mouse idle for 3 sec'); }, 3000); }); Option 2 – Capturing Mouse with Javascript (function() { […]

JQUERY AJAX different ways

Author: | Categories: Programming No Comments
Below are different ways to perform AJAX Get and Post requests through jQuery. GET request method 1 $.ajax({ url: url, data: data, success: success, dataType: dataType }); GET request method 2 $.get( "ajax/test.html", function( data ) { $( ".result" ).html( data ); alert( "Load was performed." ); }); GET request method 3 – jqXHR // […]

Waiting for AJAX response

Author: | Categories: Programming No Comments
Below code will fade out all elements in a web page till AJAX completion of request. $("body").ajaxSend(function() { $(this).append('<div id="loading">Data Loading</div>'); $('#tag').children().not('#loading').css({'opacity':0.22}); }); $("body").ajaxComplete(function() { $("div#loading").remove(); $(#tag).children().not('#loading').css({'opacity':1}); });

ASP.NET AJAX File Upload

Author: | Categories: Programming No Comments
jQuery can help in uploading a file on asp.net web page asynchronously. Add a generic handler in asp.net project like below. Upload Generic Handler – Code behind file (upload.ashx) public class upload : IHttpHandler { public void ProcessRequest(HttpContext context) { string fileName = HttpContext.Current.Request.QueryString["FileName"].ToString(); using (FileStream fs = File.Create("[Path]\\" + fileName)) { Byte[] buffer = […]

JQuery snippets

Author: | Categories: Programming No Comments
Adding text to a span using jquery $("#spanid").text("Your text here"); Adding html to a span using jquery $("#spanid").text("HTML here"); Append html to a span using jquery $("#spanid").append("HTML here"); Check/uncheck a checkbox input or radio button $("#x").prop("checked", true); $("#x").prop("checked", false); Check checkbox checked property $("#x").is(':checked') Handle change of checkbox $('#x').change(function() { if($(this).is(":checked")) { //'checked' event code […]

ASP.NET Send Canvas to Server as File Using Ajax

Author: | Categories: Programming No Comments
HTML 5 introduces canvas element as a resolution-dependent bitmap canvas which can be used for rendering graphs, game graphics, or other visual images on the fly. A canvas is a rectangle in your page where you can use JavaScript to draw anything you want. Below is the code save graphics drawn on Canvas to server […]