I am calling ajax in one function and the result should be caught in another function. It is better explained below
function myMain(){
var test = myWPackage();
alert(test);
}
function myWPackage(){
var tender_number = "TENDER_TEST-123";
//calling ajax function
$.ajax
({
url: "getWorkPackage.php",
type: "POST",
dataType: 'json',
data: {source1 : tender_number},
cache: false,
success: function (work_package)
{
return work_package[0];
})//ajax ending
}
The database if connected and the value is coming if i replace return with alert in myWPackage so there is no issue with database or the data coming.
When i call myMain() function it gives "UNDEFINED". Can anyone let me know what am i doing wrong? I am trying to ge the value from ajax to test.
thank you in advance.