I have an HTML page designed with bootstrap that calls a REST Service to update info the DB. Here is the javascript:
$.support.cors = true;
$.ajaxSetup ({
// Disable caching of AJAX responses
cache: false,
async: false
});
$("#submitemail").click(function() {
$.getJSON('http://sub.mydomain.com/getinfo/'+
encodeURIComponent($('#emailaddress').val()),
function(resp) {
//do something here
});
});
Works in FF.
Using IE – If I open the html file from my desktop and run…it will call the sub.mydomain.com and fetch the info. However, if I open the site from http://www.mydomain.com and the invoke the method – nothing. Checked with Fiddler – IE does not even send a request.
You can’t call a subdomain from your main domain like this. It’s a ‘cross-domain’ request, and the request will break. It should never work from
www.mydomain.com— even on FF.I don’t know how it does.
Anyway, how is your server built? Is the
sub.mydomain.comfolder within mydomain.com/?Such as:Top level domain:
http_public/mydomain.com/Sub Domains
http_public/mydomain.com/sub_domains/sub.mydomain.com/?
If the file structure is like this, then you can allow access directory and use
url: '/sub_domains/sub.mydomain.com/getinfo'+whateverElse, you need to use
JSONPJSONP or “JSON with padding” is a complement to the base JSON data format. It provides a method to request data from a server in a different domain, something prohibited by typical web browsers because of the Same origin policy.