简体   繁体   中英

AngularJS: trying to use jsonp for cross-domain communication

I'm trying to send the request for login using angular. Needs cross-domain communication, so using JSONP. Here is the code:

$scope.data = {"device_id":"41b72a99efb9b713","buyer_phone":"245455588","buyer_password":"mkkslkj"};
console.log($scope.data);
$scope.data = JSON.stringify($scope.data);
console.log($scope.data);
$http({
  method: 'jsonp',
  url:'https://www.application.com/app/login.php',
  data:$scope.data 
}).success(function(data, status){
    alert(data);
}) .error(function(data, status){
    console.log('Request to the API Failed');
});

But getting errors

<br />
<b>Notice</b>:  Trying to get property of non-object in           
<b>/home/yarnlive/public_html/yarntest/app/buyerlogin.php</b> on line   
<b>8</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in     
<b>/home/yarnlive/public_html/yarntest/app/buyerlogin.php</b> on line   
<b>9</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in   
<b>/home/yarnlive/public_html/yarntest/app/buyerlogin.php</b> on line   
<b>11</b><br />
{"status":"0","msg":"Invalid Username or Password","json_order":"2"}

Is I'm missing something, Please let me know. Thanks.

对于jsonp响应,应该是这样的:

callback({"status":"0","msg":"Invalid Username or Password","json_order":"2"})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM