在表单提交中启用

在表单提交中启用

本文介绍了ExtJS 6.6.0 在表单提交中启用 CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ExtJS 6.6.0

this.getForm().submit({
    url: REST.API_DOMAIN + REST.API_ATTACH + data.id,
    scope: this,
    success: function(form, result) {
        console.info(result);
    },
    failure: function(form, result) {
        console.info(result);
    }
});

尽管 REST API 是完全跨域的,ExtJS 拒绝响应.

Although the REST API is fully cross-domain, ExtJS rejects the response.

response headers HTTP/1.1 200 OK Date: Wed, 11 Jul 2018 11:41:36 GMT
Server: Apache Content-Encoding: gzip Vary:
Accept-Encoding Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: origin, x-requested-with, content-type
Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS X-Frame-
Options: ALLOW-FROM app.domain.io
Content-Length: 1335
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8

推荐答案

要使用跨域请求,您必须使用 jsonp 或者如果您仅在开发过程中需要它,您可以使用 --disable-web-security 标志运行 chrome.(编辑 chrome 的快捷方式并添加如下目标:

to use cross domain requests you must use jsonp or if you need it in only development process you can run chrome with --disable-web-security flag. (edit shortcut of chrome and add in target something like this:

C:Users{your_user}AppDataLocalGoogleChromeApplicationchrome.exe --disable-web-security --user-data-dir="G:chrome")

C:Users{your_user}AppDataLocalGoogleChromeApplicationchrome.exe --disable-web-security --user-data-dir="G:chrome")

这篇关于ExtJS 6.6.0 在表单提交中启用 CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 11:53