Jump to content

Jquery - Get


Network_ninja

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.