vue resource发送post请求问题

 this.$http.jsonp({
                url: 'http://www.xxx.com/index.php/Home/Login/loginProcess',
                method: 'POST',
                emulateJSON: true,
                data: {
                    robot:123,
                    phone:"13881119614",
                    password:"menji111",
                    usertype:0
                }
            }).then(function(response) {

                console.log(response.data);

            }, function(response) {

            });

跨域

clipboard.png

已经是jsonp了啊

XMLHttpRequest cannot load http://www.cxxx.com/index.php/Home/Login/loginProcess. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

阅读 22k
2 个回答

vue-resource 的jsonp只支持get,不支持post,如果要使用post,应该用this.$http.post

跨域问题,让你的后端工程师处理吧,让他们在响应头里加:

Access-Control-Allow-Origin: *

当然如果你对跨域问题有兴趣,推荐阅读构建public APIs与CORS

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进