Home How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?
Reply: 0

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

user801
1#
user801 Published in June 25, 2018, 4:10 am

I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created.

I've added an Ajax call into this function using jQuery:

beforecreate: function (node, targetNode, type, to) {
  jQuery.get('http://example.com/catalog/create/' + targetNode.id + '?name=' + encode(to.inp[0].value),

  function (result) {
    if (result.isOk == false) 
        alert(result.message);
  });
}

But I want to prevent my widget from creating the item, so I should return false in the mother-function, not in the callback. Is there a way to perform a synchronous AJAX request using jQuery or any other in-browser API?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.457068 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO