Advertisement
Guest User

Untitled

a guest
Nov 1st, 2013
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. function createCORSRequest(method, url){
  2. var xhr = new XMLHttpRequest();
  3. if ("withCredentials" in xhr){
  4. xhr.open(method, url, true);
  5. } else if (typeof XDomainRequest != "undefined"){
  6. xhr = new XDomainRequest();
  7. xhr.open(method, url);
  8. } else {
  9. xhr = null;
  10. }
  11. return xhr;
  12. }
  13.  
  14. var request = createCORSRequest("post", "http://xx.xxxx.com/");
  15. if (request){
  16. request.onload = function(){
  17. //do something with request.responseText
  18. };
  19. request.send(myPostObjectDataVariableGoeshere);
  20. }
  21.  
  22. SEC7118: XMLHttpRequest for http://xx.xxxx.com/ required Cross Origin Resource Sharing (CORS).
  23.  
  24. SEC7120: Origin null not found in Access-Control-Allow-Origin header.
  25.  
  26. SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
  27.  
  28. header('Access-Control-Allow-Origin: *');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement