php - Cross-Origin Request Blocked : Ajax POST with header authentication -
i'm sending ajax request php api allows post requests.
$.ajax({ url: '"//localhost/api/vs_1_0/availability"', data: $("#api-test").serialize(), type: "post", datatype: "json", headers: { "php_auth_user": "username", "php_auth_pw": "123" }, success: function (data) { alert("data server" + json.stringify(data)); }, error: function (jqxhr, textstatus, errorthrown) { alert("you can not send cross domain ajax requests: " + errorthrown); } });
when i'm sending request can see "cross-origin request blocked: " error in firebug , won't execute ajax request. have send username , password inside header $_server['php_auth_pw'] , $_server['php_auth_user'] variables. worked doing curl request. can send request server via ajax request. how can perform kind of request.
Comments
Post a Comment