javascript - Ajax call keeps getting blocked by browser -


i bit stuck issue.

i developing small mobile website. trying call webservice using ajax call, browser keeps blocking call. if start chrome using tags... "--allow-file-access-from-files --disable-web-security​​" call works perfectly. have no issues whatsoever.

now problem if host website, browser going block ajax call , user cannot example login or retrieve information. present ajax call below...

$.ajax({                 async: true,                 beforesend: function () {                 },                 complete: function () {  },                 type: 'post',                 url: 'https://mysecreturl.com/login?format=json',                 contenttype: 'application/json',                 datatype: 'json',                 data: '{"userid":"mysecretuserid","password":"mysecretpassowrd"}',                 success: function (resultmessage) {                     if (resultmessage.wassuccessful == true) {                         alert('yay');                     } else {                         alert('semi yay');                     }                 },                 error: alert('oooops')             }); 

does know workaround getting information webservice without browser blocking ajax call ?

any suggestions appreciated.

thanks in advance help.

edit

hi guys, ok did more digging , discovered following.

when request made browser security, call changes post options. called preflighted request. 1 workaround have found if making call, can use jsonp data type. problem is incompatible post. there fix not require webservice changed ?

is there fix not require webservice changed ?

no. if changing webservice isn't option, option not use browser make request.

you must either make server return data in format can accepted cross-domain, or don't make cross-domain requests browser.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -