响应成功(alert-> done),但第二个和另一个命中将响应'错误'。
我试着用'cache:false'添加一些配置参数,但仍然只能第一次使用。我应该清除一些缓存/历史或某事?
$scope.add2 = function() {
var config = {
//url : 'http://www.where2play.pl/index.php/json/getallusers',
cache: false,
//type : 'POST',
crossdomain: true,
//callback: 'JSON_CALLBACK',
//data: d,
contentType: "application/json",
dataType: "jsonp",
};
var r = Math.floor(Math.random() * 1000) + 4;
var d = {user_type_id:0, user_venue_id:0, fname:r};
var e = objToString(d);
//$http.jsonp('http://www.where2play.pl/index.php/json/adduserget?callback=JSON_CALLBACK&'+ e, config)
$http.jsonp('http://www.where2play.pl/index.php/json/adduserget?callback=JSON_CALLBACK&'+ e)
.success(function(res){
console.log('res:' + res.user);
alert('done');
})
.error(function(){
console.log('error');
alert('error');
});
};
这是jsonp and post action in ionic framework (angular.js)
新的问题,我已经添加到服务器响应“angular.callbacks._0(”前JSON数据......也许这里的错误?
这是解决方案对于我的问题: 现在我dynamiccaly获取回调参数,可以通过GET方法在服务器上变化(不总是angular.callback_0,但可以是:angular.callback_1,angular.callback_2等),并将其放在响应数据fe在PHP:
<?php header('content-type: application/json;');
$json=json_encode($result);
echo $_GET['callback'].'('.$json.')';
?>
从那里你打它,你可以提供的代码? –
我正在使用离子frm,这里是sinppets:http://codepen.io/studentttt/pen/BNPPoP – studentttt