I have a simple
$.ajax({
url: someUrl,
method: 'get',
dataType: 'html',
success: function(data) {
$('#someId').append($(data));
}
});
The problem is I can’t find elements simply within the returned data. If there’s an input with id=”myInput” I can’t get it with $(‘#myInput’) or $(‘input[id=myInput]’). I CAN find it with:
$('input').each(function(i,e){ if($(e).attr('id') == 'myInput'){ doStuff(e); } });
But who wants to do that each time? I saw this question but the solutions provided didn’t work for me. In addition to what’s up there I’ve tried
$('#someId').html(data);
$(data).appendTo($('#someId'));
and I’m using jQuery 1.4.2. Thoughts, suggestions?
The only cause of this I can think of is that your HTML syntax is malformed somewhere. Try taking out chunks of code in front of and after your myInput element and keep doing so until it functions as expected. Then slowly put pieces back in until you can identify exactly where the issue is.