ajax成功后jQuery加载div

ajax成功后jQuery加载div,jquery,ajax,Jquery,Ajax,我有一个名为news的div。它包含一些PHP代码,主要是SQL查询。当我使用表单发布一些数据时,我希望刷新我的新闻div 我尝试了一些不同的方法,但都没能成功 如果我添加类似于success:$(“#news”).load(location.href+“#news”),将在newsdiv中创建一个名为news的全新div 这是我的jQuery代码 jQuery $(document).ready(function () { // process the form $('

我有一个名为
news
的div。它包含一些PHP代码,主要是SQL查询。当我使用表单发布一些数据时,我希望刷新我的新闻div

我尝试了一些不同的方法,但都没能成功

如果我添加类似于
success:$(“#news”).load(location.href+“#news”)
,将在
news
div中创建一个名为news的全新div

这是我的jQuery代码

jQuery

    $(document).ready(function () {
    // process the form
    $('#new').submit(function (event) { // "new" is the id of my form

        // get the form data
        var formData = {
            'statustext': $("#statustext").val()
        };

        // process the form
        $.ajax({

            type: 'POST', // define the type of HTTP verb we want to use (POST for our form)
            url: '/modules/feed/process.php', // the url where we want to POST
            data: formData, // our data object
            dataType: 'json', // what type of data do we expect back from the server
            encode: true,
            success: alert(formData.statustext) // echoes the textarea input successfully, so I make sure that it works.
        })
    });
});
像这样的

success: function(data) {
  // data from the post request
  $('#news').html(data);
}

如果您的数据是html,否则您必须修改数据才能工作

如果您想在使用ajax后加载页面或一些div,则必须首先使用.load使用Jquery加载页面

<div id="newsid"></div>

<script>
$(document).ready(function () {
   $("#newsid").load("newspage.php");
});
</script>

它不起作用。我是jQuery新手,您的答案中有什么我需要更改的吗?
$(document).ready(function () {
    // load first
    $("#newsid").load("newspage.php");

    // your ajax
    $('#new').submit(function (event) { // "new" is the id of my form
        // process the form
        $.ajax({
        // your code
        })

    //load again after submit ajax
    $("#newsid").load("newspage.php");

    });

});