Tag: ajax
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() { […]
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 // […]
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}); });
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 = […]
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 […]
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 […]