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
Post a Comment