$.ajax or $.post
$.ajax or $.post
I'm trying to process a form. Here is my code:
- $.post(
"process_order.php",
$("#order").serialize(),
function(data){
$('#loader').hide();
if(data == "success") {
pTag = "<img src='http://www.heartofgold-usa.com/images/saved.png' width='200px'><br />Order Saved";
$('#popup').empty();
jQuery("#popup").append(pTag);
jQuery("#popup").dialog('open');
} else {
pTag = "<img src='http://www.heartofgold-usa.com/images/error.png' width='200px'><br />There was an error!<br /><font size='1em'>" + data + "</font>";
$('#popup').empty();
jQuery("#popup").append(pTag);
jQuery("#popup").dialog('open');
}
}
);
This may be more of a javascript problem instead of a jQuery problem. But see how I run an if else statement to see if data == "success"? It always fails that and displays my error box. And the data it actually displays in the error box is exactly "success".
I have a feeling that $.post is not the way I should go about this. Am I correct? or does it have no effect on the result?