ionic框架中的post action (angular.js)

jsonp and post action in ionic framework (angular.js)

本文关键字:angular js action post 框架 ionic      更新时间:2023-09-26

如何使用jsonp请求在数据库中存储数据?

我管理服务器/客户端和....我试过在服务器响应之前添加回调函数作为字符串,并在json请求中作为参数,但没有成功。看看我的来源(离子溶液):http://codepen.io/studentttt/pen/BNPPoP

    var d = [{"user_type_id":0, "user_venue_id":0, "fname":r}]; 
    var req = {
        type : 'POST', //'GET'
        crossdomain: true,
        //callback: 'angular.callbacks._0',
        data: d,
        contentType: "application/json",
        dataType: "jsonp",
        url : 'http://www.***.pl/index.php/json/adduser', 
};  
$http(req).success(function(res){....

当我使用GET(方法而不是POST)有相同的错误:

"NetworkError: 500 Internal Server Error - http://www.***.pl/index.php/json/adduser"

adduser错误App.js(第58行)Cross-Origin Request Blocked:同源策略不允许读取远程资源http://www.***.pl/index.php/json/adduser。(原因:CORS头'Access-Control-Allow-Origin'丢失).

JSONP只能用于GET JSON文件,它作为

<script src="..."></script>

当你这样做的时候,你不能POST。

在一个请求中不可能同时使用JSONP和POST。

更多信息参考:Post data to JsonP