简体   繁体   中英

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

In context: (cgi app in C, html with JS)
I have two html pages. 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. Based on this input, the cgi will create a new version of the other html page. (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).

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

Is this an issue of the a browser setting? Why doesn't it send anything to the cgi?






jQuery .ajax method in IE7 & IE6 not working but working fine in Firefox

Why doesn't this simple jQuery ajax work?

jQuery/Ajax call - It Doesn't work on IE7

jQuery ajax .load() not working in IE6/IE7/IE8 - Working in FF/Safari/Chrome

jquery ajax doesn't work in IE

According to the json.org specification, your return is invalid. The names are always quoted, so you should be returning { "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.

As per your edit, it seems IE is caching your Ajax request. To prevent IE from caching your Ajax requests do something like:

{
'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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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