Following is my JavaScript. How do I make the variable success global so that the changes made in ajax->success are reflected outside?
function foo() {
var success = false;
$.ajax({
type: "POST",
url: "",
dataType: "xml",
success: function(xml) {
var code = parseInt($(xml).find("Response").attr("code"), 10);
switch (code) {
case 1:
success = false;
break;
case 0:
success = true;
break;
}
}
});
return success;
}
window.success!!!success = !code. Ian got this right