Reputation: 2035
I recently started making web-based apps with JQTouch. In this app, when a button is pressed, I'm making an ajax request that gets a xml-file from my Linux server which runs Apache. When I run my app over wifi, everything is working great. When I'm over 3g and I press the button, it also loads. But when I go back and press the button again, I get an alert with error 412: precondition failed. I've searched on internet about this error and I found that I have to disable mod_security on my server, but that doesn't solve the error :(
Here's my ajax request:
$.ajax(
{
type: "POST",
cache: false,
url: "http://draughtsonline.no-ip.org/ArtObject/catalogus/catalogus.xml",
dataType: "xml",
success: function(xml)
{
// do stuff with the xml file
},
error: function(xhr, ajaxOptions, thrownError)
{
alert(xhr.status);
alert(thrownError);
},
async: false
});
I really don't know what's wrong with it. Could anyone please help me?
Thanks in advance!
Upvotes: 3
Views: 6473
Reputation: 1546
You can't POST using jQuery cross-domain. It's a security feature of JavaScript.
An alternative is to use GET and JSONP instead of POST and XML or use a relative URL.
More information:
Upvotes: 5