0

i am using simple ajax for getting data from php file and its working fine and data showing in console. But when i am trying to get the value back from success function its not returning the value. I have to get the value by passing the argument to a function.

My Code:

function getPhrase(phrase, onSuccess){
    $.ajax({
        type: 'GET',
        url: route()+'/getPhrase/'+phrase,
        data: {},
        success: function(result){
            onSuccess(result);
        }
    });
}   

and using like:

var res = getPhrase('all_rights_are_rserved', function(result){
        return result;
});

can any one tell me how i can get the result?

Rahul Sharma
  • 406
  • 3
  • 5
  • 17

0 Answers0