0

This is my whole Ajax page which is returned

 <!DOCTYPE div PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<div class="CareerAjaxData">Simple Div Content</div>

The jQuery script in the Main page which calls this Ajax page is

$.ajax({
    type : 'POST',
    url : url,
    data : data,
    datatype : 'html',
    success : function(ajaxdata) {
        var $tabcontent = $(ajaxdata).find('.CareerAjaxData');
        console.log($tabcontent.html());        
    }
});

But the output of Console gives: undefined

I get proper response from the server. But there some problem with js I guess.

whats wrong here..??

Shrey
  • 2,374
  • 3
  • 21
  • 24
  • 1
    I think your problem is that .find() matches [descendents](http://api.jquery.com/find/), while in your case ajaxData is the element your looking for. – Jack Sep 06 '12 at 13:51

2 Answers2

1

After wasting half a day.. I found the answer at https://stackoverflow.com/a/405700/920271.

Yes doctype was a typo.. but that wasn't the problem.

Using filter instead of find helped me.!

Community
  • 1
  • 1
Shrey
  • 2,374
  • 3
  • 21
  • 24
0

I don't know what type of doctype you are using. I have never seen that before. I would try a normal

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

As far as jQuery, try this:

$('#tabcontent').load('url .CareerAjaxData');
Phil
  • 10,948
  • 17
  • 69
  • 101
  • actually I needed to divs to placed in to divs of the main page.. so load was not for me – Shrey Sep 06 '12 at 15:38