[thelist] Running code on ajax success?
Tris
beertastic at gmail.com
Thu Oct 1 05:57:47 CDT 2009
Hi all..
Ajax. love it.. but today... Grrr...
I'm passing a javascript object to an external page.
What I want to happen is when it is successful, to run some code...
when it failes I get an error alert.. but when it succeeds, the sucess
code does not run... but it DOES succeed..
I want this to happen in success:
$('#headline').html("Thank you!");
but it doesn't...
Anyone know whta I'm missing??
$.ajax({
type: "POST",
url: "https://www.mysite.com/capturepage/",
data: theOrderObj,
async: false,
error: function(){
alert("that didn't work.");
},
success: function(data){
// alert('Ajax started');
var orderStat = data;
var orderStatObj = eval('(' + orderStat + ')');
if(orderStatObj.order_success == ''){
var orderFailed = "We're sorry. The address you
entered does not appear to be valid. Please review and try again";
if(orderStatObj.order_failed == orderFailed) {
alert('Ajax failed');
} else {
alert(orderStatObj.order_failed);
}
} else {
$('#headline').html("Thank you!");
}
}
});
--
"The only people who don't make mistakes are those who don't do anything"
Give a man a fish and he'll feed himself for a day.
Give a man a religion and he'll starve to death praying for a fish.
Anon
`We are what we pretend to be, so we must be careful what we pretend to be.`
Kurt Vonnegut
`When a person can no longer laugh at himself, it is time for others
to laugh at him.`
Thomas Szasz
More information about the thelist
mailing list