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
https://forums.phpfreaks.com/topic/188243-what-is-wrong-with-this/
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?

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.

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.