如何在extjs6发送Ajax来远程服务器? [英] How send Ajax to remote server in extjs6?

查看:186
本文介绍了如何在extjs6发送Ajax来远程服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用ExtJS的-6.0.0的客户端应用程序。我跑在端口80 的客户端应用程序。在 端口8084上运行我的服务器端应用程序。我想创建一个Ajax请求发送一个请求到服务器,并申请有属性如下:

I'm developing an application using Extjs-6.0.0 in client side. I run client side application in port 80. My server side application running in port 8084. I want to create an Ajax request to send a request to server and this request have attributes as follow:

输入图像的描述在这里

var json = {
    "@class": "ir.javan.geoad.entity.Melk",
    "title": "itsme",
    "description": "Hi all",
    "callPhone": "0912312312",
    "address": "ya ali",
    "accuracy": "MANTAQE",
    "user": {
        "email": "itsme.mm@gmail.com",
        "name": "asdf",
        "family": "asdf"
    }
};
Ext.Ajax.request({
    url: 'http://localhost:8084/GeoAd/ad/Add',
    useDefaultXhrHeader: false,
    method: "POST",
    cors: true,
    headers: {
        "Content-Type": "application/json"
    },
    jsonData: json,
    success: function(response){
        text = response;
    }
});

但是,这并不正常工作。 我怎样才能做到这一点

推荐答案

这是发生由于CORS。

This is happening due to CORS.

您必须禁用浏览器的安全访问这样的要求。

You have to disable the browser security to access such request.

有关Chrome浏览器下面的帖子可能对你有用 -

For Chrome following post might be useful to you -

禁用浏览器的同源策略

这篇关于如何在extjs6发送Ajax来远程服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆