0

在平台上工作,以启用自动票务功能。REST API 请求用于创建票证。不幸的是,有 2 个请求同时弹出,这导致创建重复的票证。

如何处理这种情况并只发送其中一个请求?

尝试在第一个响应回调中添加第二个请求,但这似乎不起作用。

if (flag == 1){
	logger.debug("Node-down alarm-Request raised - +sitn_id);
	clearTimeout(mouseoverTimer);
	mouseoverTimer  = setTimeout(function(){  
	logger.debug("Inside Call back function - ");
        //function call for ticket creation
	incidentRequest(sitn_id,confUtil.config.mule_url);
}, 10);
            
           

4

1 回答 1

0

您确实应该显示更多发出请求的代码,尽管您似乎在“incidentRequest”中执行了一些 ajax,所以我会假设(如果这不是您正在做的,那么请展示您的代码......) - 因为你的标签说 javascript 和 jquery - 好吧,这里是......

要在 AJAX 调用中停止“双重发送”,很简单:

function incidentRequest(sitn_id,confUtil.config.mule_url){
    // stop the double by clearing the cache
    $.ajaxSetup({cache: false});
    // continue on with the AJAX call
    // presuming the url you want is confUtil.config.mule_url
    // and the data you want to send is sitn_id
     $.post(confUtil.config.mule_url, 'sitn_id=' + sitn_id, function (data) {
         // do cool stuff
     });
}

希望这会帮助你开始行动。如果没有,那么我们将需要更多关于这一切的代码。

于 2018-09-12T02:58:32.463 回答