2
 var jqxhr = $.post("/cms/menu_pagesave", { 
   page_id: pageID,
   name : value_td,  
   url : value_url
   }, function(data) { })
   .success(function(response, textStatus, jqXHR){
   if (response) {
    menupageID = response;
    console.log(response);
    }
  });

I've got the correct response (which should be an integer) as it's turning up in the console. However it's not get assigned to the menupageID. How can I assign the value of the response to a variable? Thanks

Clinton Green
  • 9,697
  • 21
  • 68
  • 103

1 Answers1

4

You are probably attempting to using menupageID before the asynchronous response is returned. If possible, try to localize your access to the response value to be only within the success handler. In other words, put the code that needs access to menupageID also inside the success function.

Dave L.
  • 9,595
  • 7
  • 43
  • 69