Extracting Ajax return data in jQuery

后端 未结 6 1044
臣服心动
臣服心动 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 01:56

    You may also use the jQuery context parameter. Link to docs

    Selector Context

    By default, selectors perform their searches within the DOM starting at the document root. However, an alternate context can be given for the search by using the optional second parameter to the $() function

    Therefore you could also have:

    success: function(data){
        var oneval = $('#one',data).text();
        var subval = $('#sub',data).text();
    }
    

提交回复
热议问题