1

I am sending data using jquery ajax as follow to a servlet

   var dataString = 'messageid='+ msgid1+'&receivedById='+receiverid; 
    $.ajax({   
    type: "POST",   
    url: "fetchSharePage", 
    dataType: "text html",
    data: dataString,   
    success: function(data) { 

           $(".sharePost").html(data);

    }   
    }); 

Here it is showing all data as data to <div class="sharePost">.

Here I want to show only variable status and addActionMessage("Done this"); value in <div class="sharePost"> containd in data

4

1 回答 1

0

您最好更改为 JSON,然后只需执行以下操作即可:

$.ajax({
        url: "yourUrl" ,
        type: 'POST',
        cache: false,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: showItems
      });

function showItems(request, status, error) {
      $('.sharePost').append(status + ': ' + error + ' ' + request + '<br>');
    }

(这是摘自我的 showerror 代码,但只需尝试使用其中一个参数名为“状态”的函数):)

于 2013-06-24T23:03:13.050 回答