1

I'm developing an application which need CORS, I did some google but could not understand that. My application is running on localhost:8000 while I'm making a ajax request to localhost:9090. Below is my Ajax request code...

Ext.Ajax.request({
            url : 'http://localhost:9090/by-api',
            method: 'POST',
            jsonData : api_no,
            disableCaching: false,
            withCredentials: true,
            useDefaultXhrHeader: false,
            headers: {
                "Content-Type":"text/plain",
                'Access-Control-Allow-Orgin':'*',
                'Access-Control-Headers': 'x-requested-with'
            },
            success: function(response){
                console.log(response.responseText)
            },
            failure: function(response){
                console.log(response.responseText)
            }
        });

Also I want to do a Basic Authentication so I tried putting 'Authentication' in headers but nothing is working..

4

1 回答 1

1

该指令

'Access-Control-Allow-Orgin':'*'

必须在响应标头中包含服务器端,而不是在客户端请求中。按照本文档参考W3-CORS

于 2013-09-14T09:30:01.633 回答