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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -