Network_ninja Posted November 5, 2011 Share Posted November 5, 2011 Simple jquery get method: jQuery(function ($) { $('.add_cashier').click(function (e) { var id = $(this).attr("id"); $('#basic-modal-content').modal(); $.get("ajax/cashier_entry.php?id="+id, function(data) { $("#basic-modal-content").html(data); }); return false; }); }); Hi that is my simple code to get data from cashier_entry.php and loads it in a div. My question is if it is still not ready to be load I want some preloader to display. Not just a blank page and waiting for the result to come out... Tnx in advance. Quote Link to comment https://forums.phpfreaks.com/topic/250479-jquery-get/ Share on other sites More sharing options...
trq Posted November 5, 2011 Share Posted November 5, 2011 http://api.jquery.com/ajaxStart/ Quote Link to comment https://forums.phpfreaks.com/topic/250479-jquery-get/#findComment-1285131 Share on other sites More sharing options...
Network_ninja Posted November 5, 2011 Author Share Posted November 5, 2011 Tnx for the reply. Il try to read and read that link until I get it. The sample is very minimal, it's not very helpful though Quote Link to comment https://forums.phpfreaks.com/topic/250479-jquery-get/#findComment-1285133 Share on other sites More sharing options...
OAFC_Rob Posted November 5, 2011 Share Posted November 5, 2011 Do you mean you want some content to like a loading screen to appear if that field has been clicked or submited or whatever? If so an easy way to do it is have another get loaded up on the some event, passing a get variable through and then on the AJAX page have in PHP if variable is set then show loader. for example $.get("ajax/cashier_entry.php?loader="+id, function(loader) { $('#showLoader').html(loader); }); Or it coudl be done by having the laoder etc... pre coded on the page and have the CSS display set to none and if something hasn't happened ie XMLHTPP request is still loading via your get then show the loader, not too sure how to do this in jQUERY but javascript it is easy as, and rememer you can swap it about by putting javascript in jQuery. Hope that helps if I have understood ur issue correctly Quote Link to comment https://forums.phpfreaks.com/topic/250479-jquery-get/#findComment-1285205 Share on other sites More sharing options...
Network_ninja Posted November 5, 2011 Author Share Posted November 5, 2011 Or it coudl be done by having the laoder etc... pre coded on the page and have the CSS display set to none and if something hasn't happened ie XMLHTPP request is still loading via your get then show the loader, not too sure how to do this in jQUERY but javascript it is easy as, and rememer you can swap it about by putting javascript in jQuery. Hope that helps if I have understood ur issue correctly this is the one I use and it's working. tnx for the reply, I was thinking that there is something like this is jquery but haven't found one. if(document done executing the script) { display the result } else { show a preloader } Quote Link to comment https://forums.phpfreaks.com/topic/250479-jquery-get/#findComment-1285262 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.