0

I have a problem with jQuery I'm hoping someone can help with, I've replaced the content of a select box using jQuery's .load function, however if I then request the value of that box it returns the old data.

Currently the item selected is not in the new list, run the Ajax call

jQuery('#user').load(jsonurl + "?mode=list&select=users");
var user = jQuery('#user').val();

alert (user);  // Returns old value

Any ideas?

Thanks in advance.

trevrobwhite
  • 443
  • 1
  • 7
  • 22

1 Answers1

3

Access the item after the load function finishes what it is doing. You may try to read the value in the callback part of load method.

jQuery('#user').load(jsonurl + "?mode=list&select=users",function(){

   // This code will execute after load finishes. So Access now  
   var user = $('#user').val();
   alert(user);

});
Shyju
  • 214,206
  • 104
  • 411
  • 497