Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 22nd, 2012  |  syntax: None  |  size: 0.94 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jQuery ajax basic authentication is not working
  2. jQuery.ajax({
  3.   url: "https://abc.com/houses/1/appliance_hints",
  4.   method: 'GET',
  5.   cache: false,
  6.   crossDomain: true,
  7.   beforeSend: function(xhr){
  8.     xhr.setRequestHeader('Authorization', 'Basic Z3NsYWI6cGFzczFnczFhYg==');
  9.   },
  10.   success: function(result){
  11.     alert(result);
  12.   }
  13. });
  14.        
  15. Host    <host>
  16. User-Agent  Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:8.0) Gecko/20100101 Firefox/8.0
  17. Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  18. Accept-Language en-us,en;q=0.5
  19. Accept-Encoding gzip, deflate
  20. Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
  21. Connection  keep-alive
  22. Origin  <origin>
  23. Access-Control-Request-Me...    GET
  24. Access-Control-Request-He...    authorization,x-requested-with
  25.        
  26. Access-Control-Allow-Origin: http://permitted_domain.com
  27.        
  28. header('Access-Control-Allow-Origin: http://permitted_domain.com');
  29. // or to allow all
  30. header('Access-Control-Allow-Origin: *');