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 :(

我最近开始使用JQTouch制作基于Web的应用程序。在这个应用程序中,当按下一个按钮时,我正在制作一个ajax请求,从我运行Apache的Linux服务器获取一个xml文件。当我通过wifi运行我的应用程序时,一切都运行良好。当我超过3克并按下按钮时,它也会加载。但是当我再次按下按钮时,我收到错误412的警报:前提条件失败。我在互联网上搜索了这个错误,我发现我必须在我的服务器上禁用mod_security,但这并不能解决错误:(

Here's my ajax request:

这是我的ajax请求:

$.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!

提前致谢!

1 个解决方案

#1


5

You can't POST using jQuery cross-domain. It's a security feature of JavaScript.

你不能使用jQuery跨域POST。这是JavaScript的安全功能。

An alternative is to use GET and JSONP instead of POST and XML or use a relative URL.

另一种方法是使用GET和JSONP而不是POST和XML或使用相对URL。

More information:

  • Synchronous cross sub-domain POST request with jQuery
  • 使用jQuery同步交叉子域POST请求

  • jQuery AJAX cross domain
  • jQuery AJAX跨域

更多相关文章

  1. ASP.NET下使用jQuery UI下的Dialog,服务器端按钮无响应的问题。
  2. 用jquery 绑定一个按钮click事件后,第一次点击后,一切正常,第二次点
  3. JQuery 表单验证按钮提交之前变色
  4. 使用jquery实现点击按钮弹出层和点击空白处隐藏层
  5. jquerymobile phonegap back按钮获取先前状态
  6. 9.1.4 前端 - HTML body标签 - 标题,段落,分割线,换行,特殊符号,列
  7. Jquery中的事件处理(自动触发事件,禁用按钮,悬停,失焦,滑动效果)
  8. 你能告诉为什么javascript函数没有在profile.php的提交按钮中执
  9. html5中点击按钮,改变按钮状态效果样式

随机推荐

  1. 转:6410下点亮led
  2. Linux常用命令汇总-速查
  3. Linux 3.4.39内核编译配置选项介绍
  4. linux shell脚本编程笔记(四): 获取字符串长
  5. linux apache安装https证书
  6. 有什么办法可以在Windows上不用使用太繁
  7. 线程同步-生产者消费者问题
  8. linux下touch命令也可以一次创建多个文件
  9. linux如何处理多连接请求?
  10. Linux下安装配置MongoDB数据库图解