是否可以在Magento 2后端异步触发多个Ajax请求? [英] Is it possible to fire multiple ajax requests asynchronously in Magento 2 backend?

查看:71
本文介绍了是否可以在Magento 2后端异步触发多个Ajax请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题怎么说. 我试图用AJAX调用1"运行导入脚本,我想跟踪AJAX调用2"的导入(出于反馈目的). 为了向最终用户提供实时反馈,这些调用需要同时运行,并且调用2"需要自行调用(递归)以轮询更改.

What the title says. Im trying to run an import script with AJAX "call 1" and I want to keep track of the import (for feedback purposes) with AJAX "call 2". To give the end user live feedback these calls need to run simultaneously and "call 2" needs to call itself (recursive) to poll for changes.

我有控制器和电话,一切正常,只是在同一时间. 是对数据库的软锁还是其他?

I have the Controllers and the calls and everything works just fine, just not at the SAME time. Is it a soft lock on the database or is it something else?

顺便说一句,我知道ajax调用的"async:true"设置.

Btw I am aware of the "async: true" setting for the ajax call.

看来Magento阻止我同时执行两个控制器.有人可以确认吗?

[edit] It looks like Magento is preventing me from executing two controllers at the same time. Can anyone confirm this?

推荐答案

好了,我知道了.

我所要做的就是设置:

session_write_close();

在开始导入的方法之前,我可以通过第二个AJAX调用开始轮询!

In front of the method that started the import and I could start polling with a second AJAX call!

这可能让人不满意,但可以使用

This is probably frowned upon, but it works

这篇关于是否可以在Magento 2后端异步触发多个Ajax请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆