Jump to content

What is wrong with this?


aeroswat

Recommended Posts

Ok it is alerting error2. After it alerts error2 it alerts bla22... self recursion? wtf?

 

	function update(fInp, valu) {
	alert('bla1');
	var ord = document.getElementById('ctrordernumber').value;
	alert('bla2');
	alert (fInp.length);
	alert (valu.length);
	if(fInp.length != 0 && valu.length != 0){
		$.post("updateorder-exec.php", {field: ""+fInp+"", val: ""+valu+"", on: ""+ord+""}, function(data){
			alert('bla22');
			if(data.length >0) {
				alert('bla3');
				if(data) {
					//$('#errDiv').show();
					//$('#errDiv').html("Database updated!");
					alert('updated');
					//$('#errDiv').css('opacity',100).fadeOut(10000);
				} else{
					alert('error');
					//$('#errDiv').show();
					//$('#errDiv').html("Error. Incorrect information entered!");
					//$('#errDiv').css('opacity',100).fadeOut(10000);
				}
				return data;
			}
		});
	}
	alert('error2');
	//$('#errDiv').show();
	//$('#errDiv').html("Error. Incorrect information entered!");
	//$('#errDiv').css('opacity',100).fadeOut(10000);

	return 0;
}

Link to comment
Share on other sites

You call alert('bla22') in the callback function, so that doesn't get triggered until your file is loaded with $.post. It just keeps going on with the code and then executes the callback function when the file is actually loaded.

 

Why does it matter, though?

 

I found out I need a synchronous call :P Everything has to be done in order because this function is not returning the information that it needs to return before another function executes what it needs to do.

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.