[FX.php List] [ off ] Quick JQuery question

Dale Bengston dale.bengston at gmail.com
Sun Jun 30 15:53:17 MDT 2013


Bob,

I have done this by using $.ajax() to submit a form and act on the results. $.ajax() in jQuery comes with all sorts of built-in goodies that let you do things like use post for the form so your target PHP script gets data just as though the form were submitted traditionally. It also has pre- and post-submit settings, like beforeSend, and callbacks for success, error, complete, etc. You could use the complete callback to wait until the ajax call is done to run a 2nd function.

Here's a simple one that replaces the content of a details record with a busy "loading" gif before it makes a GET request for a different record. Then on success, it swaps in the new content. It doesn't use POST because I'm not submitting a form via ajax.

var loaderGif = '<img src="https://mysite.com/img/busy_orange.gif" alt="Loading" />';

function refreshDetail (itemNumber) {
	$.ajax({
		beforeSend: function(){
			$("#DetailWell").hide().html(loaderGif).fadeIn("fast")
		},
		url: "https://mysite.com/Products/product_detail/" + itemNumber,
		success: function(detail) {
			$("#DetailWell").hide().html(detail).fadeIn("slow");
		}
	});
}

Hope this helps,
Dale

On Jun 30, 2013, at 3:24 PM, Denis Somar <dsomar at gmail.com> wrote:

> I believe there is a function called enqueue for JavaScript or jquery that queues all processes
> 
> 
> On Sun, Jun 30, 2013 at 4:01 PM, James Dcunha <jdcunha at supportgroup.com> wrote:
> 
> I normally return a status flag value back to the callback function. Based on the flag value it would execute the 2nd process. 
> 
> James 
> 
> Sent from my Phone 
> 
> On Jun 30, 2013, at 3:16 PM, Bob Patin <bob at patin.com> wrote: 
> 
> > Did it a different way... I added JQuery to the process page so that it loads the guest page AFTER the PHP has done its thing... works fine... 
> > 
> > But I seem to recall someone (Steve Winter?) telling me about a way to have a 2nd process occur after the 1st has concluded... 
> > 
> > BP 
> > 
> > On Jun 30, 2013, at 1:31 PM, Bob Patin <bob at patin.com> wrote: 
> > 
> >> I have a function that adds an element to an array; after that happens I want to do this 
> >> 
> >> reload a main page; 
> >> reload a subsidiary page that takes the array and makes a table out of it 
> >> 
> >> Sometimes it works right, sometimes not, when I use this line: 
> >> 
> >> // process GUEST_ADD form 
> >> $('.content').delegate('#guestform', 'submit', function(){ 
> >> var str = $('#guestform').serialize(); 
> >> $('.content').fadeOut(200).load('guest_process.php?'+str).load('guest.php').fadeIn(200); 
> >> window.scrollTo(0, 0); 
> >> return false; 
> >> }); 
> >> 
> >> So as you can see, I'm submitting a form, processing it with "guest_process.php"; then, I want to reload "guest.php" which in turn calls a page that loads in my array as a table. 
> >> 
> >> I'm thinking that the 2nd LOAD needs to wait for the first to finish, is that correct, and if so, how do I write it? I vaguely recall having to do this in a page on another project, but can't find the code now. 
> >> 
> >> Thanks for any help, 
> >> 
> >> Bob 
> >> 
> >> Bob Patin 
> >> Longterm Solutions LLC 
> >> P.O. Box 3408 
> >> Brentwood, TN 37024 
> >> bob at longtermsolutions.com 
> >> 615-333-6858 
> >> http://www.longtermsolutions.com 
> >> iChat: bobpatin 
> >> AIM: longterm1954 
> >> Twitter: bobpatin 
> >> Google+: http://www.longtermsolutions.com/plus 
> >> -- 
> >> FileMaker 9, 10 & 11 Certified Developer 
> >> Member of FileMaker Business Alliance and FileMaker TechNet 
> >> -- 
> >> FileMaker hosting and consulting for all versions of FileMaker 
> >> PHP • Full email services • Free DNS hosting • Colocation • Consulting_______________________________________________ 
> >> FX.php_List mailing list 
> >> FX.php_List at mail.iviking.org 
> >> http://www.iviking.org/mailman/listinfo/fx.php_list 
> > 
> > _______________________________________________ 
> > FX.php_List mailing list 
> > FX.php_List at mail.iviking.org 
> > http://www.iviking.org/mailman/listinfo/fx.php_list 
> _______________________________________________ 
> FX.php_List mailing list 
> FX.php_List at mail.iviking.org 
> http://www.iviking.org/mailman/listinfo/fx.php_list 
> 
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list