0

I want to get stored value in my defined variable. I have written this code:

 var phn=$.ajax({
url:   ipaddress+"/.../.../...",
type: "POST",
    data: JSON.stringify(MyForm1),
    contentType: "application/json; charset=utf-8", 
    success:function(response){
        console.log(response);
        $.each(response, function(k, v) {
                rcvdResponse.push(v);
                console.log(rcvdResponse);
        }); 
        var phone =rcvdResponse[0];
        return phone;
        }

    });

rcvdResponse is a defined array. But it is not returning the output. Can anyone help me to do it?

SGhosh
  • 41
  • 4

1 Answers1

0

You can't use return sentence in the ajax's success callback...

Use this method instead (creating your own callback function)

Regards.

Community
  • 1
  • 1