国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

angular.js - When jQueryMobile is integrated with angularJS to make ajax requests, why does the post request fail, but the get request does?
世界只因有你
世界只因有你 2017-05-15 17:10:20
0
1
710

Both the html page and the php page are sure to be correct. When using jquerymobile and angularjs to make an ajax request, why is the post request unsuccessful, but the get request is OK? The js code is as follows:

angular.module('kaifanla',['ng','ngTouch']).controller('orderCtrl',function ($scope,$http,parseSearch) {
  $scope.isSubmit=false;
  var did=parseSearch(location.search).did;
  $scope.order={did:did};
  $scope.submit=function () {
    $scope.isSubmit=true;
   // var str=jQuery.param($scope.order);
   //  $http.get('../data/order_add.php?did='+did+'&user_name='+$scope.order.user_name+'&sex='+$scope.order.sex+'&phone='+$scope.order.phone+'&addr='+$scope.order.addr).
   //  success(function (data) {
   //    console.log(data);
   //    $scope.oid=data.oid;
   //  })
    var str=jQuery.param($scope.order);
    $http.post('../data/order_add.php',str).success(function (data) {
      console.log(data);
    })
  }
  }).
service('parseSearch', function () {
  return function (search) {   //可以在所有的Controller中使用的一個(gè)函數(shù)——Service
    /*將形如'?did=2&pno=3&uname=tom&loc=bj轉(zhuǎn)換為一個(gè)對(duì)象'*/
    var result = {};
    search = search.substring(1);
    var arr = search.split('&');  //['did=3', 'pno=5', 'uname=tom']
    angular.forEach(arr, function (v, k) {
      var kv = v.split('=');
      result[kv[0]] = kv[1];
    })
    return result;
  }
})
世界只因有你
世界只因有你

reply all(1)
PHPzhong

Does your php backend have a post interface? I think you only opened the get type interface.

In addition, I don’t know what the agreed data format of your backend is. The data you have here is a string passed through jq’s param. If you do not specify the header of the content format to be sent, your backend may not know it. How to parse. Or directly parse the formbody as a string.

A previous article may be useful to you
http://blog.anchengjian.com/#...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template