Why does this jQuery Ajax call fail ONLY in IE9 (Even works fine in IE8 and IE7)

后端 未结 2 1075
余生分开走
余生分开走 2021-01-02 05:44

I have a website where I make an ajax call like this:

            // perform an ajax request to generate a new subscriber account
            jQuery.ajax({
          


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 06:26

    Are you sure that the URL you're calling (/index.php?option=com_content&view=article&id=45&tmpl=component) works in IE9? If you load that PHP page up in IE9, does it return the expected result? It should do, but it's worth checking that the error is in the jQuery call, rather than the PHP.

    Also, a POST call would usually be to a page like 'index.php', with the query string (option=com_content, view=article etc.) sent as the variable postVars.

    Try using the following:

    $.ajax({
        type: "POST",
        url: "index.php",
        data: {
            option : com_content,
            view : article,
            id : 45,
            tmpl : component
        },
        success: function(msg){
            console.log(msg);
        },
        error: function(jqXHR, textStatus, errorThrown) {
            console.log(textStatus)
        }
    });
    

    Strip down the function to its basic parts, and you should be able to see where the error is coming from.

提交回复
热议问题