Search Results

Search found 15 results on 1 pages for 'ajaxstop'.

Page 1/1 | 1 

  • jquery ajaxstart ajaxstop show hide

    - by user1630583
    As usually seemingly simple things take days to resolve, maybe someone could point me to a solution but after 2 days I give up on the following problem; In html, in a form I have a button that is supposed to trigger loading of data through ajax call: <button type="" class="btn" onclick="getData(); return false;">Show Data</button> in javascript: $(document).ajaxStart(function() { $("#qloader").show(); }).ajaxStop(function() { $("#qloader").hide('slow'); });? and in html div with id qloader is defined with 100% width and height and spinner centered as the background, z-index above other: <div id="qloader" class="myLoader" >&nbsp;</div> Now, when page loads, ajax call is executed to get initial data, qloader div is brought up and it shows the spinner - animated, after ajax call finishes, qloader is hidden by ajaxStop. Next, when I click on a button (show data) to initiate another ajax call, ajaxStart is triggered, but it does not show qloader, it waits until ajaxStop is triggered and then in a blink of eye it shows qloader and hides it. I suspected that ajaxStart is not executed, so I put alert before $("#qloader").show(), then alert would be displayed and after that qloader WOULD be displayed BUT spinner animation would be suspended - no spinning, and after ajaxStop it would get hidden. Without alert in ajaxStart trigger, in subsequent ajax calls div is not shown until just before ajaxStop is triggered. It works fine for the first ajax call, but for subsequent ajax call triggered by click on form button it does not work. Any idea what is wrong with this setup?

    Read the article

  • Simplify your Ajax code by using jQuery Global Ajax Handlers and ajaxSetup low-level interface

    - by hajan
    Creating web applications with consistent layout and user interface is very important for your users. In several ASP.NET projects I’ve completed lately, I’ve been using a lot jQuery and jQuery Ajax to achieve rich user experience and seamless interaction between the client and the server. In almost all of them, I took advantage of the nice jQuery global ajax handlers and jQuery ajax functions. Let’s say you build web application which mainly interacts using Ajax post and get to accomplish various operations. As you may already know, you can easily perform Ajax operations using jQuery Ajax low-level method or jQuery $.get, $.post, etc. Simple get example: $.get("/Home/GetData", function (d) { alert(d); }); As you can see, this is the simplest possible way to make Ajax call. What it does in behind is constructing low-level Ajax call by specifying all necessary information for the request, filling with default information set for the required properties such as data type, content type, etc... If you want to have some more control over what is happening with your Ajax Request, you can easily take advantage of the global ajax handlers. In order to register global ajax handlers, jQuery API provides you set of global Ajax methods. You can find all the methods in the following link http://api.jquery.com/category/ajax/global-ajax-event-handlers/, and these are: ajaxComplete ajaxError ajaxSend ajaxStart ajaxStop ajaxSuccess And the low-level ajax interfaces http://api.jquery.com/category/ajax/low-level-interface/: ajax ajaxPrefilter ajaxSetup For global settings, I usually use ajaxSetup combining it with the ajax event handlers. $.ajaxSetup is very good to help you set default values that you will use in all of your future Ajax Requests, so that you won’t need to repeat the same properties all the time unless you want to override the default settings. Mainly, I am using global ajaxSetup function similarly to the following way: $.ajaxSetup({ cache: false, error: function (x, e) { if (x.status == 550) alert("550 Error Message"); else if (x.status == "403") alert("403. Not Authorized"); else if (x.status == "500") alert("500. Internal Server Error"); else alert("Error..."); }, success: function (x) { //do something global on success... } }); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Now, you can make ajax call using low-level $.ajax interface and you don’t need to worry about specifying any of the properties we’ve set in the $.ajaxSetup function. So, you can create your own ways to handle various situations when your Ajax requests are occurring. Sometimes, some of your Ajax Requests may take much longer than expected… So, in order to make user friendly UI that will show some progress bar or animated image that something is happening in behind, you can combine ajaxStart and ajaxStop methods to do the same. First of all, add one <div id=”loading” style=”display:none;”> <img src="@Url.Content("~/Content/images/ajax-loader.gif")" alt="Ajax Loader" /></div> anywhere on your Master Layout / Master page (you can download nice ajax loading images from http://ajaxload.info/). Then, add the following two handlers: $(document).ajaxStart(function () { $("#loading").attr("style", "position:absolute; z-index: 1000; top: 0px; "+ "left:0px; text-align: center; display:none; background-color: #ddd; "+ "height: 100%; width: 100%; /* These three lines are for transparency "+ "in all browsers. */-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)\";"+ " filter: alpha(opacity=50); opacity:.5;"); $("#loading img").attr("style", "position:relative; top:40%; z-index:5;"); $("#loading").show(); }); $(document).ajaxStop(function () { $("#loading").removeAttr("style"); $("#loading img").removeAttr("style"); $("#loading").hide(); }); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Note: While you can reorganize the style in a more reusable way, since these are global Ajax Start/Stop, it is very possible that you won’t use the same style in other places. With this way, you will see that now for any ajax request in your web site or application, you will have the loading image appearing providing better user experience. What I’ve shown is several useful examples on how to simplify your Ajax code by using Global Ajax Handlers and the low-level AjaxSetup function. Of course, you can do a lot more with the other methods as well. Hope this was helpful. Regards, Hajan

    Read the article

  • Jquery ajax load of JSON in unit tests

    - by wmitchell
    I'm trying to load a dataset in jasmine for my tests like such ... However as its a json call I cant seem to always get the test denoted by "it" to wait till the JSON call has finished before using its array. I tried using the ajaxStop function to no avail. Any ideas ? describe("simple checks", function() { var exampleArray = new Array(); beforeEach(function(){ $(document).ajaxStop(function() { $(this).unbind("ajaxStop"); $.getJSON('/jasmine/obj.json', function(data) { $.each( json.jsonattr, function(i, widgetElement) { exampleArray.push(new widget(widgetElement)); }); }); }); }); it("use the exampleArray", function() { doSomething(exampleArray[0]); // frequently this is coming up as undefined });

    Read the article

  • ajaxStart only called once

    - by cmroanirgo
    I'm having trouble with ajaxStart/ajaxStop. In the following code, the ajaxStart/ajaxStop code is only ever called once (the very first time). Any ideas why? var A_func = function() { $.get($(this).attr("href"), function(response) { $("#content_inner").replaceWith($("#content_inner", response)); }); return false; }; $(function() { $("A").live("click", A_func); $(document).ajaxStart(function(){$("#loading").show();alert("loading");}); $(document).ajaxStop(function(){$("#loading").hide();alert("finished");}); }); Note that the ajax requests themselves work correctly, it's just that the 'loading' icon only shows the once and then never again. My html is something like: <body> <img id="loading" width="12" height="12" src="/images/ajax-loader.gif" style="display:none" alt="loading"/> ... <div id="content"><div id="content_inner"...</div></div>... </body> I have also tried using ajaxSend/ajaxComplete and it has the same problem

    Read the article

  • jQuery modal dialog on ajaxStart event

    - by bdl
    I'm trying to use a jQuery UI modal dialog as a loading indicator via the ajaxStart, ajaxStop / ajaxComplete events. When the page fires, an Ajax handler loads some data, and the modal dialog shows just fine. However, it never hides or closes the dialog when the Ajax event is complete. It's a very small bit of code from the local server that is returned, so the actual Ajax event is very quick. Here's my actual code for the modal div: $("#modalwindow").dialog({ modal: true, height: 50, width: 200, zIndex: 999, resizable: false, title: "Please wait..." }) .bind("ajaxStart", function(){ $(this).show(); }) .bind("ajaxStop", function(){ $(this).hide(); }); The Ajax event is just a plain vanilla $.ajax({}) GET method call. Based on some searching here and Google, I've tried altering the ajaxStop handler to use $("#modalwindow").close(), $("#modalwindow").destroy(), etc. (#modalwindow referred to here as to give explicit context). I've also tried using the standard $("#modalwindow").dialog({}).ajaxStart(... as well. Should I be binding the events to a different object? Or calling them from within the $.ajax() complete event? I should mention, I'm testing on the latest IE8, FF 3.6 and Chrome. All have the same / effect.

    Read the article

  • JQuery Ajax control

    - by Anycolor
    Everybody hi. There is a problem with my own AJAX library, that I can't solve. I have some block (#ajax-loading), that has events: $('#ajax-loading') .bind('ajaxStart', function() { $('#ajax-loading').show(); }) .bind('ajaxStop', function() { $('#ajax-loading').fadeOut(150); }); For running AJAX I have special method: run: function(data, callback) { if(this.request) { this.request.abort(); } this.request = $.getJSON(window.location.pathname, data , callback); }, So .request holds current AJAX request. What do I want? My #ajax-loading block contains the button, than should Cancel current AJAX request. As I supposed, the function, making Cancel shoud contain: abort: function() { if(ajax.request) { this.request.abort(); $('#ajax-loading').fadeOut(150); } } But, as I said, there is a problem: my AJAX request cancels, loading-block hides, but when another request starts, this block doesn't shows again. It seems that when I abort AJAX request, the ajaxStop event doesn't happen. And when I run new request ajaxStart doesn't happen. I think it can be connected with readyState or status field of XMLHttpRequest, or smth similar. Could anyone help me with this or explain what's wrong. PS: excuse my english, it's not my native language...

    Read the article

  • AjaxStart issue

    - by Jerry
    Hi All I am trying to build a shopping website with ajax. When a user clicks the "add to cart" image. The little loading image will show next to the Add To Cart Image. The first click works fine and the image showed as I expected. However, the second and the following clicks appends more images on the first loading image(2nd:add two loading images, 3rd: add three images..6 total images after 3 clicks). I did use ajaxStop and remove the first image...Not sure what's going on...Could use a help. Thanks a lot. My javascript code // add to cart $(".addToCart").click(function(e){ $this=$(this); $tableId=$this.closest('table').attr('id'); $($this).prev().ajaxStart(function(){ $("<img class='loader' src='images/loader.gif'>").insertBefore($this); }); $($this).prev().ajaxStop(function(){ $($this).prev().remove(); }); HTML <table> <tr> <td width="146" align="right" valign="middle"> <br> <span id="wasPrice"><?php echo $productPriceWas; ?></span> <br> <?php echo "$".$productPrice;?><br>**//I want my image here**<a class="addToCart" href="javascript:void(0);"><img src="images/addToCart.gif" alt="add To Cart"/><a/> </td> </tr> </table>

    Read the article

  • Jquery ajaxStart doesnt get triggered

    - by gnomixa
    This code $("#loading").ajaxStart(function() { alert("start"); $(this).show(); }); in my mark-up <div style="text-align:center;"><img id="loading" src="../images/common/loading.gif" alt="" /></div> Here is the full ajax request: $.ajax({ type: "POST", url: "http://localhost/WebServices/Service.asmx/GetResults", data: jsonText, contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { var results = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; PopulateTree(results); }, error: function(xhr, status, error) { var msg = JSON.parse(xhr.responseText); alert(msg.Message); } }); $("#loading").ajaxStart(function() { alert("start"); $(this).show(); }); $("#loading").ajaxStop(function() { alert("stop"); $(this).hide(); $("#st-tree-container").show(); }); never fires alert "start" even though the gif is shown to rotate. AjaxStop gets triggered as expected. Any ideas why?

    Read the article

  • $.blockUI loading mask

    - by usman
    hi, i am using jQuery BlockUI Plugin (v2) to block and unblock while loading and when on clicking some button.but my problem is masking is working fine while loading page but it is not working when we click button,here is my code $("input[name^=filtera]").click(function(){ $.blockUI({message:'<h3><img src="images/spinner.gif" /> Please Wait...</h3>'}); $.ajax({ url : "ChangeRequestSearch.action?last_date_modified=" + modifiedDate , cache: false, success : function (data) { $("#tableLoader").html(data); } }); $().ajaxStop($.unblockUI); }); i am getting the Error: $.blockUI is not a function let me know what is the problem Thanks Usman.sk

    Read the article

  • Display loading while webservice is running

    - by poseid
    On the initial request to a page, I trigger a webservice and want to display a loading message. When the page has finished loading, I want to remove the waiting message from screen, but display it again when a change event in a checkbox triggers an Ajax call with another loading message. This code is not behaving to the given spec: $(document).ready( $(function() { $('#loadingDiv').hide(); $('#productsDropDown') .change(function() { var prodValue = $(this).val(); $('#proddate').load('getpdate.php', {prod: prodValue }); }); $('#loadingDiv') .ajaxStart(function() { $(this).show(); }) .ajaxStop(function() { $(this).hide(); }) ; }); ); what am I doing wrong?

    Read the article

  • jQuery ajax not preloading images

    - by George Wiscombe
    I have a list of galleries, when you click on the title of a gallery it pulls in the contents (HTML with images). When the content is pulled in it preloads the html but not the images, any ideas? This is the JavaScript i'm using: $('#ajax-load').ajaxStart(function() { $(this).show(); }).ajaxStop(function() { $(this).hide();}); // PORTFOLIO SECTION // Hide project details on load $('.project > .details').hide(); // Slide details up / down on click $('.ajax > .header').click(function () { if ($(this).siblings(".details").is(":hidden")) { var detailUrl = $(this).find("a").attr("href"); var $details = $(this).siblings(".details"); $.ajax({ url: detailUrl, data: "", type: "GET", success: function(data) { $details.empty(); $details.html(data); $details.find("ul.project-nav").tabs($details.find(".pane"), {effect: 'fade'}); $details.slideDown("slow"); }}); } else {$(this).siblings(".details").slideUp();} return false; }); You can see this demonstrated at http://www.georgewiscombe.com Thanks in advance!

    Read the article

  • ajaxStart() showing loading message doesn't seem to work....

    - by Pandiya Chendur
    I user jquery.ajax call to controller of asp.net mvc... I would like to show a loading indicator.. I tried this but that doesn't seem to work... <div class="loading" style="padding-left:5px; margin-bottom:5px;display:none;"> Loading...&nbsp </div> and my jquery ajax call looks like this, function getMaterials(currentPage) { $.ajax({ url: "Materials/GetMaterials", data: {'currentPage': (currentPage + 1) ,'pageSize':5}, contentType: "application/json; charset=utf-8", global: false, async: false, dataType: "json", success: function(data) { var divs = ''; $("#ResultsDiv").empty(); $.each(data.Results, function() { //my logic here.... $(".loading").bind("ajaxStart", function() { $(this).show(); }).bind("ajaxStop", function() { $(this).hide(); }); } }); return false; } My loading indicator doen't seem to showup.. ANy suggestion....

    Read the article

  • AJAX Request Erroring

    - by 30secondstosam
    I can not figure out for the life of me why this is erroring - can someone please cast a second pair of eyes over this - it's probably something really stupid, thanks in advance for the help: EDIT Stupidly I was putting the wrong URL in - HOWEVER... Now I have put the correct URL in, the site just hangs and crashes. Any ideas please? HTML: <input id="pc" class="sfc" name="ProdCat[]" type="checkbox" value=""> <input id="psc" class="sfc" name="ProdSubCat[]" type="checkbox" value=""> <input id="bf" class="sfc" name="BrandFil[]" type="checkbox" value=""> JQuery: $('input[type="checkbox"]').change(function(){ var name = $(this).attr("name"); var ProdCatFil = []; var ProdSubCatFil = []; var BrandFil = []; // Loop through the checked checkboxes in the same group // and add their values to an array $('input[type="checkbox"]:checked').each(function(){ switch(name) { case 'ProdCatFil[]': ProdCatFil.push($(this).val()); break; case 'ProdSubCatFil[]': ProdSubCatFil.push($(this).val()); break; case 'BrandFil[]': BrandFil.push($(this).val()); break; } }); $("#loading").ajaxStart(function(){ $(this).show(); $('.content_area').hide(); }); $("#loading").ajaxStop(function(){ $(this).hide(); $('.content_area').show(); }); $.ajax({ type: "GET", url: '../ajax/ajax.php', data: 'ProdCatFil='+ProdCatFil+'&ProdSubCatFil='+ProdSubCatFil+'&BrandFil='+BrandFil, success: function(data) { $('.content_area').html(data); } }).error(function (event, jqXHR, ajaxSettings, thrownError) { $('.content_area').html("<h2>Could not retrieve data</h2>"); //alert('[event:' + event + '], [jqXHR:' + jqXHR + '], [ajaxSettings:' + ajaxSettings + '], [thrownError:' + thrownError + '])'); }); PHP (just to prove it's working): echo '<h1>TEST TEST TEST </h1>'; The errors from JQuery alert box: [event:[object Object]], [jqXHR:error], [ajaxSettings:Not Found], [thrownError:undefined])

    Read the article

  • Help me please, javascript place problem or another thing??

    - by ilkdrl
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Urunler.aspx.cs" Inherits="Urunler" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en" /> <link href="rss/example_ticker.css" rel="stylesheet" type="text/css" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script src="rss/jquery.zrssfeed.min.js" type="text/javascript"></script> <script src="rss/jquery.vticker.js" type="text/javascript"></script> <title></title> <script type="text/javascript" src="lightbox/js/prototype.js"></script> <script type="text/javascript" src="lightbox/js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="lightbox/js/lightbox.js"></script> <link rel="stylesheet" href="lightbox/css/lightbox.css" type="text/css" media="screen" /> <style type="text/css"> ........... ........... ........... <td style="background-color: #808080"> <script type="text/javascript"> $(document).ready(function () { $('#ticker1').rssfeed('http://www.xxxxxxx.com/map.asp').ajaxStop(function () { $('#ticker1 div.rssBody').vTicker({ showItems: 3 }); }); }); </script> <div id="ticker1" > </div> Hi, i have two scripts.lightbox and rss. lightbox script works very well in mywebform1 but rss feed dont work.I didnot solve that?Help me please. PS: on the other hand, my another webpage(mywebform2) in same website has only rss feed and works very well.

    Read the article

  • JQuery Mobile Code Snippets 1

    - by Yousef_Jadallah
     I want to share with you some important codes that you may need during JQuery Mobile development.These codes are tested on Alpha 4 version. Beta 1 has been released before two days, Therefore I will test them in my current project and let you know if there is any changes : Normal 0 false false false EN-US X-NONE AR-SA /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}    Normal 0 false false false EN-US X-NONE AR-SA /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;} Show and hide back button in your Application    $(document).bind("mobileinit", function () {           $.mobile.page.prototype.options.addBackBtn = true;        });     Customizing the back button text $(document).bind("mobileinit", function () {$.mobile.page.prototype.options.backBtnText = "previous";});       Hide "Close button" for dialog programatically:   $('[data-role=dialog]div[id="YourDiaogdivID"]').live('pagecreate', function (event) {     $("a[data-icon='delete']").hide();          });  Change Select option element index:      var myselect = $("select#foo");       myselect[0].selectedIndex = 0; //The new index        myselect.selectmenu("refresh"); //uset this line of code after any updating on the select element      Change Select optoin elemetn text value:    $("select#foo").parent().contents().children('.ui-btn-text').text('Your Text Here');    Refreshing a checkbox    $("select#foo").parent().contents().children('.ui-btn-text').text('Your Text Here');     Hide select option element  $('#foo').parent().hide();     Hide and Show Page Loading Message :  $.mobile.pageLoading(); //Show $.mobile.pageLoading(true); //hide            overriding $.mobile.loadingMessage  $(document).bind("mobileinit", function () {    $.mobile.loadingMessage = 'My Loading Message';    });    Hide and Show jQuery-Mobile-Themed-DatePicker    $(".ui-datepicker").hide();  $(".ui-datepicker").show();       Build your Custom Loading Message :           $('#CustomeLoadingMessage').hide();//Hide the div               $('# CustomeLoadingMessage').ajaxStart(function () {                $(this).show();            });             $('# CustomeLoadingMessage').ajaxStop(function () {                $(this).hide();            });   I wil publish other important codes soon.Hope that helps.

    Read the article

1