javascript - passing headers with ajax in jquery -


i have problem passing headers in ajax call on jquery.

$.ajax({     url: '/resources/ajax/customize.aspx?' + qs + '&nocache=' + math.random(),     contenttype: "application/json",     headers: values,     context: $this,     cache: false,     success: function(data) {           //do stuff here     } }); 

in cases, gets headers values right, doesn't headers value. made sure 'values' variable contains data. wondering there specific cases headers don't pass in ajax?

update: tried as:

 $.ajax({      url: '/resources/ajax/customize.aspx?' + qs + '&nocache=' + math.random(),      contenttype: "application/json",      beforesend: function(xhr) { xhr.setrequestheader('values',values); },      //headers: values,      context: $this,      cache: false,      success: function(data) {                   //do stuff here      }  }); 

and there no luck that.

update 2

figured out problem. there url variable line breaks in it, line breaks caused headers not passed.

i facing same issue. got rid of line breaks using jquery's(or in js otherwise) $.trim() method. in case knew \n\r won't part of value legally. has checked trim fix it.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -