0

I have a jquery ajax which returns some html as data.

success: function(data){
$('#ajaxresponse ul.display li input').each(function(index) {

ajax response is a div which comes from jquery ajax success data. How to get the html from the response?

1
  • $(data).find('ul.display li input') Commented Jan 16, 2014 at 15:12

2 Answers 2

3

You can use find() method in jQuery

success: function(data){
$(data).find('#ajaxresponse ul.display li input').each(function(index) {
  ........................
});

Documentation:http://api.jquery.com/find/

Sign up to request clarification or add additional context in comments.

2 Comments

i think #ajaxresponse is the wrapping element returned by ajax request but anyway +1
@A.Wolff : that may depend upon his response , I can't make any prediction :)
0

you can append it to your html DOM where your want it to go, then do as you do now:

success: function(data){
$("#YourDiv").after(returnValue);
$('#ajaxresponse ul.display li input').each(function(index) {

where returnValue is a var containing the data returned by your ajax

1 Comment

Don't need to append. See Pranav Ram's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.