I have a mobile ajax-rich website, that I want to put to phonegap to create "app". Website uses $.ajax extensivly, but to make it work inside pnonegap app, I have to declare domain in url settings.
Here is usual call, that I use now:
$.ajax({
url: '/authentication/login',
success: function(data){}
})
And here is what it supposed to look like to make it work inside an app:
$.ajax({
url: 'http://my-domain.com/authentication/login',
headers: {'X-Requested-With': 'XMLHttpRequest'},
success: function(data){}
})
As you can see, the only difference is that I have to set domain inline and I have to set header (that's needed for the backend).
I don't want to rewrite whole project and set domain in every ajax call, because it will prevent developent site call (when domain is localhost), so I wonder how do I modify $.ajax to rely on some GLOBALs - if e.g. SET_DOMAIN global is present, I want to add that domain name to each and every ajax call. Same with headers.
This way I will have to declare SET_DOMAIN and SET_HEADERS once, and can do it only in phonegap project, leaving regular website untouched.
Thanks in advance!