0

I am trying to print the username from the given search result array but it does not print anything. Currently, I am trying to append the value from all_users array of loop with key and value format such as username: value.user.username, and now i am printing with another loop, but it's now working.

Please check the below attachment for array coming enter image description here

Php Dev
  • 61
  • 6
  • The call to `.get` is asynchronous and returns immediately; when you try to access `search_result` in the line after it, the `.get` has not finished and so `search_result` is still empty. You need to move that code into your `.done` function. – Nick Aug 22 '20 at 07:34

1 Answers1

1

$(search_result).each(function(index, result) { // Not working this console.log(result.username); }); The above line must be inside your ajax call's success function definition.

Asutosh
  • 1,775
  • 2
  • 15
  • 22