您的位置:首页 > Web前端 > JavaScript

angular Js使用get方式ajax访问后台数据 非跨域访问

2018-01-02 09:58 363 查看
angular Js使用get方式ajax访问后台数据 非跨域访问。记得引angularJS包啊 啊啊啊啊啊。话不多说,直接上代码。

$http({

method : 'GET',//声明方式
url:"/reimbursement/reim/reimSubmit.action",//访问地址
params:{//参数
reimcode:"116066cf11734b24871333a3fbf4abea",
               "type" : "0",
"loginname" : "liu_wei",
"prono" : "107C107N1U014F77",
"billps" : 1,
"totalmoney" : "12569",
"test" : JSON.stringify(s),
saddress:"北京",
eaddress:"大连",
sdate:"20171215",
edate:"20171218",
trallow:5000000,
toreason:"出差能干嘛",
loanamt:50000000,

               }
}).then(function successCallback(response) {//执行成功后回掉
console.log(response);
}, function errorCallback(response) {
// 请求失败执行代码
});

post方式:

$http({

method : 'POST',//声明方式
url:"/reimbursement/reim/reimSubmit.action",//访问地址
 params:{//参数
 reimcode:"116066cf11734b24871333a3fbf4abea",
            
   "type" : "0",
"loginname" : "liu_wei",
"prono" : "107C107N1U014F77",
"billps" : 1,
"totalmoney" : "12569",
"test" : JSON.stringify(s),
saddress:"北京",
eaddress:"大连",
sdate:"20171215",
edate:"20171218",
trallow:5000000,
toreason:"出差能干嘛",
loanamt:50000000,

               }
}).then(function successCallback(response) {//执行成功后回掉
console.log(response);
}, function errorCallback(response) {
// 请求失败执行代码
});

很简单吧,哈哈,有什么不懂的可以给我留言,收到后会第一时间回复哦
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐