Question : Serialize ajax requests with jQuery


 Hi Experts!

I have the code attached bellow. If an ajaxRequest is currently running I would like to block the user to make another one until the current one finished. How can I do this with the function I have?

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
function serializeUserCommentAjaxFunction(url, loaderImageDiv, formData, callback) {

	var postAjaxComment = function() {

		var loader = "#" + loaderImageDiv + "";
		
		var isQue = false;
		var isRequestRunning = false;
		
		if (!isRequestRunning) {
			jQuery.ajax( {
				type : "POST",
				url : url,
				dataType : "html",
				data : formData,
				cache : false,
				beforeSend : function() {
					jQuery(loader).show();
				},
				error : function() {
					// jQuery('input').hide();

				// error code
			},
			complete : function() {
				jQuery(loader).hide();
			},

			success : function(response) {

			}
			});
		} else {

		}
	}
}

Answer : Serialize ajax requests with jQuery

Hmm... Another question answered in this book!
http://www.sitepoint.com/books/phpmysql4/

It sounds like you're new to building web sites.  If that is the case, RUN (don't walk) to your local Junior College and ask them for their course list on the use of these technologies:

HTML
CSS
PHP

Then get a web hosting account with a competent hosting company.  Cost: pennies a day.  Build some test sites, learn through experimentation, and from your college classes.  You will get good results, but don't expect to become a professional in a year or two -- it's a field of endeavor that is changing rapidly.

Best of luck with your projects, ~Ray
Random Solutions  
 
programming4us programming4us