jquery ajax chaining

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

jquery ajax chaining

Post by s.dot »

How to chain jquery ajax calls to execute in a linear fashion?

My attempt:

Code: Select all

$.get(
	'script.php', { t: 2, k: 18, u: '8032' }, function() {
		alert('done1');
		$.get(
			'script.php', { t: 5, k: 18, u: '48' }, function() {
				alert('done2');
			}
		)
	}
);
No alerts, so I figure it's not executing.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: jquery ajax chaining

Post by Weirdan »

Works fine for me on jquery.com site:

Code: Select all

$.get("http://jquery.com", function() { console.log("1"); $.get("http://jquery.com", function () { console.log("2"); }); });
XMLHttpRequest
1
2
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: jquery ajax chaining

Post by kaszu »

Maybe script.php returns 404?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: jquery ajax chaining

Post by pickle »

Ya - use Firebug to see your requests & the results thereof.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply