asp.net - JSONP isn't returning data in https -


i spent friday on this, , figured i'd come in on monday , see if can help. here's summary:

i have 2 websites, 1 uses ajax call @ http handler on website token (string) back. used json call works great, when site i'm accessing uses https, data isn't returned.

i 200 success message back, , data using http, not https. having issue working on local machine. verify if use same url, data returned in browser.

also, when in https mode, set breakpoint , looks doesn't call code pass token.

thanks in advance!

         function onsuccessgettoken(token, url, type) {          var gettokenurl = url + "ssotoken=" + token;           //verify url correct, testing          alert(gettokenurl);           $.ajax({              url: gettokenurl,              contenttype: "application/json; charset=utf-8",              datatype: "json",              success: function (msg) {                  onsuccess(json.stringify(msg).replace(/\"/g, ""), url, type);              },              error: function (msg) {                  //using jsonp, goes here, no data returned                  alert(json.stringify(msg));                  onerrorgettoken(msg);              }          });      } 

you haven't shown gettokenurl contains, problem description i'd you're running same origin policy, prevents ajax calls between different "origins." note "origin" not mean "domain", different domains different origins, different protocols (http vs. https), different ports (80 vs. 8080 instance), etc.

in question, talk jsonp, you're not using jsonp. can use jsonp handle cross-origin requests, that's it's for. that, use "jsonp" datatype , make sure server returns correct jsonp response (including getting name of jsonp callback query string). more jsonp in the wikipedia article on it.

another strategy doing cross-origin calls when control both origins use cross-origin resource sharing. server responds "preflight" request browser sends tells browser whether server accept call document's origin. browser support pretty these days outside of ie. in ie9 , earlier, it's supported, not via standard xmlhttprequest object (which jquery uses). of ie10, right.


unrelated: ajax call, you're specifying contenttype: "application/json". that's telling server you're sending json, not telling jquery treat response json. that's other one, datatype, you're specifying (although properly-configured server, shouldn't have to — server should return content-type header correct mime type).


Comments