0

我尝试通过 Ajax 将表单发送到另一个页面的服务器端,保存它并留在同一页面中。

阿贾克斯代码:

function SaveJS() {
    $.ajax({
        type: "POST",
        url: 'http://' + $('#ip').val() + 'EditSochen.aspx?id=3',
        data: $('#form1').serialize(),
        success: function () {
            $('#div2').css("display", "none")
        }
    });
}

'http://' + $('#ip').val() + 'EditSochen.aspx?id=3' 页面中的服务器代码:

if (Page.IsPostBack)
        {
            Response.Clear();            //clears the existing HTML
            Response.ContentType = "text/plain";  //change content type
            Response.Write("fgf");    //writes out the new name
            Response.End();             //end
        }

它到达另一个页面的服务器端但返回另一个页面而不是留在同一页面,为什么?

谢谢,

4

1 回答 1

0

我发现了问题 - 我需要return falseSaveJS()func.

代码:

function SaveJS() {
    $.ajax({
        type: "POST",
        url: 'http://' + $('#ip').val() + 'EditSochen.aspx?id=3',
        data: $('#form1').serialize(),
        success: function () {
            $('#div2').css("display", "none")
        }
    });
return false;
}
于 2013-04-23T14:04:44.693 回答