tags:

views:

37

answers:

2

Hi all, could someone please explain why the following code is throwing an error?

// JavaScript Document
$(document).ready(function(){
    $(".port-box").css("display", "none");
    $('ul#portfolio li a').bind('click', function(){
        var con_id = $(this).attr("id");
        if( con_id.length !== 0 ) {
            $.get('./act_web_designs_portfolio', function(data){
                var content = data.find("#" + con_id + "-content").html();
                alert(content);
            });
            return false;
        }
    });
});

Firefox says:

data.find is not a function

Any help much appreciated, regards, Phil

+3  A: 

data is going to be a string.

If you're expecting data to contain HTML, try

var content = $(data).find(....)
Pekka
! thanks, forgot about that.
Phil Jackson
A: 

Because data is not a jQuery object - it's usually a string containing the markup of the returned page.

Use `$(data).find(...)' instead - that will probably do it.

belugabob