简体   繁体   English

为什么IE7中的JQuery AJAX调用不起作用? (对于此特定示例)

[英]Why doesn't the JQuery AJAX call work in IE7? (for this specific example)

I did see the links below but unfortunately nothing seemed applicable to my code. 我确实看到了下面的链接,但不幸的是,似乎没有适用于我的代码的链接。

This function works in FF but not in IE, to simply send a name value pair (info/"") to the server. 此功能在FF中有效,但在IE中不起作用,只是将名称值对(info /“”)发送到服务器。 Don't need to return anything or call any other function. 不需要返回任何东西或调用任何其他函数。

Any suggestions? 有什么建议么?

function functionAX()
{ 
    $(document).ready(function() {

       $.ajax({
           url: "/cgi-bin/app.exe",
           method: "post",
           async: false,
           data: { info: "" }
       });

    });
}


Thank You. 谢谢。

EDIT 编辑
It appears this ajax call works - but only the first time it is called. 看来此ajax调用有效-但仅在第一次调用时。

In context: (cgi app in C, html with JS) 在上下文中:(C中的CGI应用程序,带有JS的HTML)
I have two html pages. 我有两个HTML页面。 On each page is a header with a tab/link of both pages. 每个页面上都有一个带有两个页面的选项卡/链接的标题。 When clicking on the other page/tab, I call this function functionAX() that sends the name/value pair to the cgi executable. 当单击另一页/选项卡时,我调用此函数functionAX(),该函数将名称/值对发送到cgi可执行文件。 Based on this input, the cgi will create a new version of the other html page. 基于此输入,cgi将创建另一个html页面的新版本。 (With async:false, the old page will lock until the new page is loaded and that is fine for this application, as long as I get a fresh page after hitting the tab/link to that page). (使用async:false,只要我在点击该页面的选项卡/链接后得到一个新页面,旧页面就会锁定,直到加载新页面为止,这对于此应用程序来说是正确的)。

So when I go back to "page 2" and select "page 1" (a second time from page 2) it no longer calls the function or sends anything to the cgi app... 因此,当我返回“第2页”并选择“第1页”(第2页的第二次)时,它不再调用该函数或将任何内容发送到cgi应用...

Is this an issue of the a browser setting? 这是浏览器设置的问题吗? Why doesn't it send anything to the cgi? 它为什么不向cgi发送任何内容?






jQuery .ajax method in IE7 & IE6 not working but working fine in Firefox IE7和IE6中的jQuery .ajax方法无法正常运行,但在Firefox中可以正常运行

Why doesn't this simple jQuery ajax work? 为什么这个简单的jQuery ajax无法正常工作?

jQuery/Ajax call - It Doesn't work on IE7 jQuery / Ajax调用-在IE7上不起作用

jQuery ajax .load() not working in IE6/IE7/IE8 - Working in FF/Safari/Chrome jQuery ajax .load()在IE6 / IE7 / IE8中不起作用-在FF / Safari / Chrome中工作

jquery ajax doesn't work in IE jQuery Ajax在IE中不起作用

According to the json.org specification, your return is invalid. 根据json.org规范,您的返回无效。 The names are always quoted, so you should be returning { "info": "" } 名称总是用引号引起来,因此您应该返回{ "info": "" }

This may not be the problem with your setup, since you say one of them works with FF/etc, but it should be fixed for correctness in case you need to switch to another JSON parser in the future. 这可能不是设置的问题,因为您说其中一个可以与FF / etc一起使用,但是为了确保正确性,应该对其进行修复,以防将来需要切换到另一个JSON解析器。

As per your edit, it seems IE is caching your Ajax request. 根据您的编辑,看来IE正在缓存您的Ajax请求。 To prevent IE from caching your Ajax requests do something like: 为了防止IE缓存您的Ajax请求,请执行以下操作:

{
'info': '',
'random' : Math.random()
}

I think you should do either: 我认为您应该执行以下任一操作:

$(document).ready(function() {

   $.ajax({
       url: "/cgi-bin/app.exe",
       method: "post",
       async: false,
       data: { info: "" }
   });

});

or 要么

function functionAX()
{ 
       $.ajax({
           url: "/cgi-bin/app.exe",
           method: "post",
           async: false,
           data: { info: "" }
       });
}

It seems weird combining both the function and document.ready 将功能和文档结合起来似乎很奇怪

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM