I am doing a simple jQuery post:
$.post('/form.html',
$("#form").serialize(),
function(data, textStatus) {
//Selector for finding a field in the data
});
How do I process a selector against the variable data?
I need to look for a specific id that exists within the html
returned from the post call?
Is the data a block of HTML that has an HTML element with an id?
For example, say the data returned from the post looks like
and say that you just want to pull out the value of the “hiddenField” element. You can do
The
$(data)part in the selector is creating a context in which the selector will operate.$("#hiddenField", $(data) ).val()is the exact equivalent of doing$(data).find("#hiddenField").val().