angular 中的 jsnop 总是出错?
always get error with jsnop in angular?
在 Web 控制台中检查时加载 jsnop 文件。但我也得到 "ajax Failed"
var loginuser = $http.jsonp( 'http://livegap.com/interior/users/login.php?callback=JSON_CALLBACK', { params :{username: "username",password:"password"}});
.success(function(data) {
//$scope.myData.fromServer = data.title;
alert("AJAX Success!");
})
.error(function(data) {
alert("AJAX failed!");
});
login.php
<?php
header('content-type: application/jsonp; charset=utf-8');
?>
[{
"loginUserName":"<?php echo $_REQUEST['username']?>","loginPassword":"<?php echo $_REQUEST['password']?>"
}]
改变login.php
在函数中插入我的数据
该函数的名称来自 $_GET['callback']
<?php
header('content-type: application/json; charset=utf-8');
echo $_GET['callback']?>([{"loginUserName":"<?php echo $_REQUEST['username']?>","loginPassword":"<?php echo $_REQUEST['password']?>"}])
在 Web 控制台中检查时加载 jsnop 文件。但我也得到 "ajax Failed"
var loginuser = $http.jsonp( 'http://livegap.com/interior/users/login.php?callback=JSON_CALLBACK', { params :{username: "username",password:"password"}});
.success(function(data) {
//$scope.myData.fromServer = data.title;
alert("AJAX Success!");
})
.error(function(data) {
alert("AJAX failed!");
});
login.php
<?php
header('content-type: application/jsonp; charset=utf-8');
?>
[{
"loginUserName":"<?php echo $_REQUEST['username']?>","loginPassword":"<?php echo $_REQUEST['password']?>"
}]
改变login.php 在函数中插入我的数据 该函数的名称来自 $_GET['callback']
<?php
header('content-type: application/json; charset=utf-8');
echo $_GET['callback']?>([{"loginUserName":"<?php echo $_REQUEST['username']?>","loginPassword":"<?php echo $_REQUEST['password']?>"}])