Extracting Ajax return data in jQuery

后端 未结 6 1037
臣服心动
臣服心动 2020-11-29 01:36

I have done jQuery and Ajax, but I am not able to get the response into a Div element. This is the code:

Index.html

$.ajax({
    typ         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 02:12

    You can use .filter on a jQuery object that was created from the response:

    success: function(data){
        //Create jQuery object from the response HTML.
        var $response=$(data);
    
        //Query the jQuery object for the values
        var oneval = $response.filter('#one').text();
        var subval = $response.filter('#sub').text();
    }
    

提交回复
热议问题