I have a table that开发者_如何学JAVA gets sorted by a certain column when the user selects an option from the drop-down. It is a self-referencing PHP script that contains an IF clause for a GET request.
Since it is a self-referencing file, it returns the entire HTML content of the page, so I need a single div returned. The entire response returns fine, but jQuery find always returns null for any div.
Also, the response data always returns "string" even though I have specified html. I'm not sure if this is relevant or not.
This is what I have so far:
function sortTable()
{
var by=encodeURIComponent(document.getElementById("sort").value)
$.ajax({
type: "GET",
url: '/tasks?sort=',
data: by,
dataType: "html",
success: function(data) {
var tmp = data;
var test = $(tmp).find("sort-table");
alert(test.html());
},
});
I think you are missing something
var test = $(tmp).find(".sort-table");
or
var test = $(tmp).find("#sort-table");
var test = $(tmp).find("div.sort-table");
it will find div
s with class sort-table
That was work for me
$(data).filter('div.test');
here is link Use Jquery Selectors on $.AJAX loaded HTML?
精彩评论