[英]Can php handle multiple http post request at the same time?
我正在处理 angularjs 项目,其中有 2 个用户管理员和办公室人员。要将数据插入数据库,我需要使用 post 方法使用 http 请求将数据发送到服务器,并且此请求在服务器端以 php 接收。 这是对带有一些参数的服务器的简单请求,它可以正常工作,直到用户点击提交按钮和同时发出 http 请求。 即当两个用户同时发出 http 请求时。如果发生这种情况,第二个请求不会得到任何响应。现在我的问题是有没有办法检查服务器是否正在处理一个 http 请求并发出第二个请求等待。
角度:
$http({
method: "post",
url: $localStorage.weburl + "abc.php?f=abc_data",
timeout: 1 * 10 * 2000,
params: {
action: "add"
},
data: {
data1: data1,
data2: data2
}.then(function mySucces(response) {
}, function myError(err) {
$ionicLoading.hide();
alert("Please check the connection");
})
});
PHP:
function abc_data($conn)
{
$_POST = json_decode(file_get_contents('php://input'), true);
}
你应该像这样尝试
var deferred = $q.defer();
$http.post($localStorage.weburl + "abc.php",{action: "add"})
.success(function (data) {
deferred.resolve(data);
})
.error(function (error) {
deferred.reject(error);
});
return deferred.promise;
如果您使用的是post
方法,则传递您的数据,例如{data:arrayOfdata}
而不是url: $localStorage.weburl + "abc.php?f=abc_data"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.