jquery - assign value to global variable in javascript -
i want assign value global variable in javascript jquery ajax function.
var truefalse; $.ajax({ type: "get", url: "url", data: "text=" + $("#text").val(), success: function(msg) { if(msg.match(/ok/) != null) { truefalse = "true"; } else { truefalse = "false"; } } }); return truefalse;
here need value of truefalse success function.
thanks v.srinath
if can't change application logic, have create "synchronous" ajax request (by setting async:false
in $.ajax
options), wait until "get" has executed , return value caller.
otherwise, should rewrite code success function calls callback function can proceed whatever has done.
Comments
Post a Comment