Use Jquery Selectors on $.AJAX loaded HTML?

前端 未结 9 788
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 11:30

I have

$.ajax({
  url: identity,
  success: function(data) { ProcessIdentityServer(data) }
});

When \'data\' is returned, is there a way to

相关标签:
9条回答
  • 2020-11-27 12:28
    // Finds all div elements within an XML document from an AJAX response.
    $("div", xml.responseXML);
    
    0 讨论(0)
  • 2020-11-27 12:29

    You have to define a container first, to be able to get/modify the elements from the response:

     $.ajax({            
         url: url + "/ajax.htm",
         dataType: "html",
         success: function(html) {
             container = $('#ajax_content');
             container.html(html);
             container.find("a").css("background","red");
         }
     });
    
    0 讨论(0)
  • 2020-11-27 12:34

    Sure you can use the $(data) function, one of the core jquery functions, to turn the returned html into DOM elements. Check out the docs online.

    0 讨论(0)
提交回复
热议问题