javascript - Not able to send header with xhrfield -


i trying flipkart api data . not able send heder xhrfield here code :

$.ajax({     type: 'get',     url:'https://affiliate-api.flipkart.net/affiliate/search/json?query=iphone+mobiles&resultcount=3',     crossdomain: true, //    datatype: 'jsonp',     /*xhrfields: {             withcredentials: true         },*/   //    contenttype: 'application/json; charset=utf-8',        beforesend : function(xhr) {         xhr.withcredentials = true;                 xhr.setrequestheader('fk-affiliate-id', 'myid');         xhr.setrequestheader('fk-affiliate-token', 'mytoken');       },    /*   headers: {         'access-control-allow-origin':'*',         'fk-affiliate-id': 'myid',         'fk-affiliate-token': 'mytoken',         'content-type': 'application/x-www-form-urlencoded'       },*/      success: function(data){ ...... } }); 

as can see comment ahve tried both not able send header xhrfield . if comment xhrfield header wil send

you can not send header jsonp requests since set script tag page.

a jsonp requests consists of appending script tag page. adds callback parameter url script listens when script executed. there no way add header external script.

the site need support json request cors send header.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -