开发者

Why isn't AJAX working in IE?

Anything I'm missing with the code below? I'm a bit overwhelmed.

$("a[id^='submitspam']").click(function () { 
    var thisForm = $(this).attr('id');
    var com_id = $(this).attr('id').substring(11);
    var thisFormFull = '#' + thisForm;

    $.ajax({  
 开发者_如何学C       type: "POST",
        url: "/songs/spam.php",
        data: "command=mark_spam&cid=" + com_id,

        complete: function(data){
            messageList = 'contentspam-' + com_id;
            $('span#' + messageList).html(data.responseText);
            $(thisFormFull).hide();
            $('span#' + messageList).fadeIn();
        }
    });

    return false;  
});


Works for me. I created a jsfiddle with your code, and clicking the link in IE 8 generates a request. I used Fiddler to inspect the HTTP request:

POST /songs/spam.php HTTP/1.1
x-requested-with: XMLHttpRequest
Accept-Language: en-US,en;q=0.7,es;q=0.3
Referer: http://fiddle.jshell.net/josh3736/Ghy5C/show/
Accept: */*
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; .NET CLR 1.1.4322; .NET4.0C; InfoPath.3)
Host: fiddle.jshell.net
Content-Length: 23
Connection: Keep-Alive
Pragma: no-cache

command=mark_spam&cid=1

Even though the AJAX request 404s (there's no spam.php on jsfiddle's server), the link is hidden after the request completes. As an aside, you should make your callback function the success callback rather than the complete callback, so that your UI does not report that an operation succeeded when in fact there was an error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜