JavaScript callback on ajax for setting variable value

I am calling a callback function after ajax call as shown below.

 var mypage= {};
 var mypagebox = {
   somefunction: function() {
     var self = this;
     self.createID(obj, function(resp) {
       if (resp.ERRORSTATUS == 0) {
         
         mypage.newID = resp.newID;
         console.log("pooped in array ");
         console.log(mypage.newID);
       }
       console.log("outside if ");
       console.log(newID.newID);
     });
     console.log("outside scope ");
     console.log(mypage.newID);
   },
   createID: function(_obj, callback) {
     $.ajax({
       headers: {
         'Content-Type': "application/json; charset=utf-8",
         'dataType': "json"
       },
       data: {
         //Some data
       },
       url: "/url"
     }).done(function(res, d) {
       callback(JSON.parse(res));
     });
   }
 };
Answer:1

I have a markup that looks like the following: <div class="accordion is-open"> <h3 class="accordion-header"> HADER <span class="accordion-indicator"></span>...

I have a markup that looks like the following: <div class="accordion is-open"> <h3 class="accordion-header"> HADER <span class="accordion-indicator"></span>...

  1. click remove class jquery
  2. click remove class
  3. click anywhere remove class jquery
  4. click add remove class jquery
  5. body click remove class
  6. click outside remove class
  7. on click remove class javascript
  8. click outside remove class jquery
  9. body click remove class jquery
  10. click function remove class
  11. ng-click remove class
  12. js click remove class
  13. document click remove class
  14. window click remove class
  15. click button remove class
  16. vue click remove class
  17. if click remove class
  18. double click remove class jquery
  19. on click remove class from parent div
  20. second click remove class

I'm using vuejs in my project and noticed that when a page is in loading state, I see something like this {{ user.id }} {{ user.name }} which is very annoying. And after the page is fully loaded, I ...

I'm using vuejs in my project and noticed that when a page is in loading state, I see something like this {{ user.id }} {{ user.name }} which is very annoying. And after the page is fully loaded, I ...

I have a rectangle on an SVG element. I then want to draw another rectangle over the whole SVG area except the rect I've already drawn. I thought masks might be a solution but they seem to act just ...

I have a rectangle on an SVG element. I then want to draw another rectangle over the whole SVG area except the rect I've already drawn. I thought masks might be a solution but they seem to act just ...

I'm using jQuery to create a simple addClass on hover. Hovering over a #science-panel-number div triggers a class of .active to be added to an #iphone-screen-number div. Here is my jQuery: $('#...

I'm using jQuery to create a simple addClass on hover. Hovering over a #science-panel-number div triggers a class of .active to be added to an #iphone-screen-number div. Here is my jQuery: $('#...

  1. number with jquery validate
  2. number with commas jquery
  3. format number with jquery
  4. random number with jquery
  5. number counter with jquery
  6. increment number with jquery
  7. number with decimal jquery
  8. add number with jquery
  9. increase number with jquery
  10. replace number with jquery
  11. number jquery
  12. number jquery plugin
  13. number jquery animation
  14. number jquery form validation
  15. number jquery selector
  16. number jquery check
  17. number counter animation with jquery
  18. validate phone number with jquery
  19. class with number jquery