When I ran into this problem, I simply put this information as a data item in a tag.
<body data-base="http://mydomain.com"> ...
And then used this to create the correct URL for this request:
//If pathOrURL is a relative path (eg /users/1), then we return a qualified // URL, such as http://mydomain.com/users/1 // otherwise, we return the URL as is var qualifyURL = function(pathOrURL) { if (!(new RegExp('^(http(s)?[:]//)','i')).test(pathOrURL)) { return $(document.body).data('base') + pathOrURL; } return pathOrURL; }; //Use this helper function when calling $.ajax $.ajax({ url: qualifyURL(url), ... });
This worked great with my phone. Hope this helps.
source share