[英]Returning HTTP status codes in Codeigniter using Angular.js
I created a simple submit page using codeigniter and angular.js. 我使用codeigniter和angular.js创建了一个简单的提交页面。 How can I throw HTTP status codes after somebody clicked submit button, so the the user will know if it is successful or not, or any other reason why it failed? 有人单击“提交”按钮后,我如何抛出HTTP状态代码,以便用户知道它是否成功,或失败的任何其他原因?
BTW, I base my code in this post Codeigniter + Angular Js: How to receive JSON data 顺便说一句,我在这篇文章中基于我的代码Codeigniter + Angular Js:如何接收JSON数据
Don't use .success()
IMHO. 不要使用.success()
恕我直言。 Use .then()
instead. 使用.then()
代替。
.then(function(resp){
var $status = resp.status //http status code
var $data = resp.data //data back from the server
});
If you're set on using success
, then check out all the arguments for the success
function: 如果您打算使用success
,那么请检查一下success
函数的所有参数:
success(function(data, status, headers, config)
As usual, check the docs when you'er in doubt 与往常一样, 如有疑问 , 请检查文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.