javascript - Why do browser blocks specific Ajax requests? -
i have 2 code snippets:
$.getjson("https://noembed.com/embed", {"format": "json", "url": input.val()}, function (data) { // work data });
the second one:
$.getjson("https://www.youtube.com/oembed", {"format": "json", "url": input.val()}, function (data) { // work data });
the first 1 successful, second 1 not. both sent http://localhost:8080/myapp/page
. why same origin policy not permit both requests? (actually it's question browsers).
some servers permit browsers cross origin requests, not. see cors.
there can multiple cors headers involved, either none of them present or required particular operation missing youtube. but, point server decides if wants permit cross origin operations browsers , 2 servers offering different capabilities in regard.
this particular youtube api bit suspect though because exists purely cross-origin reasons there must else going on preventing working. learn more, 1 have @ network trace see being sent youtube, cors headers present , perhaps might causing this. could, example, there http/https mismatch , that's why cors failing?
Comments
Post a Comment