Why does this script result in 'undefined' when the value is returned from the Ajax call?
function myShippingApp() {
this.shipper = 0;
this.init() {
this.getShipRate();
alert(this.shipper);
}
this.getShipRate = function() {
var zip = $('zip').value;
if(zip == '') {
return false;
} else {
var url = 'getrate.php?zip='+zip;
this.shipper = new Ajax.Request(url, {
onComplete: function(t) {
$('rates').update("$"+t.responseText);
return t.responseText;
}
});
}
}
}
I'm working with Prototype framework, and having trouble returning the value back to object. What am I doing wrong?
Thank you!