ajax cross domain not working in jquery -


error :

response preflight request doesn't pass access control check: 'access-control-allow-origin' header contains multiple values 'http://localhost:8080, *', 1 allowed. origin 'http://localhost:8080' therefore not allowed access.

$("#selector3").autocomplete({             source: function(request, response) {                                 $.ajax({                    url: "http://example.com/"+$("#selector3").val(),                     type: "get",                         datatype: "json",                         data: request,                         processdata: true,                         data: {},                          headers: {                              "access-control-allow-origin" : "*",                             "access-control-allow-headers": "origin, content-type, accept"                                     },                          crossdomain: true,                     success: function(data) {                            alert(data.company_id); }); 

please use jsonp cross domain scripting.

check below sample code:

$.ajax({     url: "http://example.com/" + $("#selector3").val(),     type: "get",     datatype: 'jsonp', // notice! jsonp <-- p (lowercase)     data: request,     processdata: true,     data: {},     headers: {         "access-control-allow-origin": "*",         "access-control-allow-headers": "origin, content-type, accept"     },     success: function(data) {         alert(data.company_id);     } }); 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -