Synchronous Ajax - does Chrome have a timeout on trusted events?

后端 未结 3 1733
忘了有多久
忘了有多久 2021-02-05 13:25

Situation

We have a situation, where we need to onclick-open a new tab in browsers after performing an XHR / Ajax request.

We do this by setti

3条回答
  •  隐瞒了意图╮
    2021-02-05 13:45

    Hello @ChristopherLörken. Can you give a example code or a fiddle of what are you doing? Maybe I'm not understanding what you want.

    I think this will help:
    If you need the event in your context, you can save the reference of the event for posterior use, like in a callback. Example using jQuery:

    $(myBtn).click(function(ev){
       var event = ev; //Save the event object reference
       $.ajax({
       // ... your options
       success: function(res){
         //do stuff with the event in the callback
         console.log(event);
       });
    });
    

    In this way, you don't need call a sync request to use the event in your context and, as a async request, chrome don't complain with that. :)

提交回复
热议问题