开发者

Ajax request not working in IIS

This code runs in Visual Studio but not in IIS.

$('#addMessage').click(function () {
    var textMessage = $('#ticketMessage').val();
    var isInternal = $('#isInternal')开发者_开发知识库[0].checked;
    var ticketID = $('#TicketID').val();
    $.ajax({
        url: '/Ticket/AddMessage',
        type: 'POST',
        data: { textMessage: textMessage, isInternal: isInternal, ticketID: ticketID },
        success: function (data) {
            var tbody = $('#allMessages').children()[0];
            tbody.innerHTML = tbody.innerHTML + data;
            $('#ticketMessage').val("");
            $('#isInternal')[0].checked = false;
        }
    });
});

What to fix in this code for the ajax request to run properly in IIS?


Please check with URL, Because sometimes the URL may point to 404 error page. Because, the file is hosted in virtual folder. So, Please try with fully URL first, to check if it work fine. Better use Firebug or IE 9 developer tools. we can trace the Ajax requests.

I mean like this

$.ajax({
    url: 'http://localhost/yourapplication/Ticket/AddMessage',
    type: 'POST',
    data: { textMessage: textMessage, isInternal: isInternal, ticketID: ticketID },
    success: function (data) {
    var tbody = $('#allMessages').children()[0];
    tbody.innerHTML = tbody.innerHTML + data;
    $('#ticketMessage').val("");
    $('#isInternal')[0].checked = false;
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜