drn1008 2019-02-15 10:04
浏览 424

php可以同时处理多个http post请求吗?

I'am working on angularjs project in which there are 2 users admin and office staff.And to insert data to database i need to send data to server using http request using post method and this request is received on server side in php. This is simple request to server with some parameters and its working correctly until both the users hit submit button and http request is made at the same time. ie when http request is made by both the users at the same time.If that happens than 2nd request is does not get any response.Now my question is that is there a way to check if server is processing one http request and make 2nd request wait.

angularjs:

$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);
}   
  • 写回答

1条回答 默认 最新

  • dongwai4434 2019-02-15 10:27
    关注

    You should try like this way

    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;
    

    If you are using post method then pass you data like {data:arrayOfdata} instead of url: $localStorage.weburl + "abc.php?f=abc_data"

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入