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
https://forums.phpfreaks.com/topic/250479-jquery-get/
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
https://forums.phpfreaks.com/topic/250479-jquery-get/#findComment-1285205
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
https://forums.phpfreaks.com/topic/250479-jquery-get/#findComment-1285262
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.