2

I'm trying to do a simple REST api in a CakePhp app, using a REST plugin I found, which for Authorization uses http headers.

My question is, how can I supply through jQuery using json, a header like for example:

Authorization: TRUEREST username=wwwww&password=zzzzz&apikey=xxxxxyyyyyyy

random_user_name
  • 25,694
  • 7
  • 76
  • 115
pedrosss
  • 57
  • 4
  • 11

1 Answers1

5
$.ajax({
  // ...
  beforeSend: function(x) {
    x.setRequestHeader('Authorization', 'TRUEREST username=wwwww&password=zzzzz&apikey=xxxxxyyyyyyy');
  },
  // ...
});

Docs: http://api.jquery.com/jQuery.ajax/

sje397
  • 41,293
  • 8
  • 87
  • 103
  • Thanks for the reply! Will try and next time read better the docs :) – pedrosss Jul 01 '11 at 00:56
  • 1
    @pedross The docs aren't all that helpful in this case. I got some info from this q as well, tho it's not really relevant: http://stackoverflow.com/questions/249692/jquery-wont-parse-my-json-from-ajax-query – sje397 Jul 01 '11 at 00:58