JQuery Ajax Get Data Syntax error, unrecognized expression:

Using the latest jQuery (1.9.0), I am confused why this code does not work:

$.testAjaxFilter = function() {

    var base = this;

    // get faq categories
    var currentFaqCategories = $('#category-list ul li a');

    // loop through each faq category link and bind a click event to each
    if ( typeof currentFaqCategories !== 'undefined') {

        $.each(currentFaqCategories, function(index, category) {

            $(category).click( function(e) {
                $(e.target).getFaqList();
                return false;
            });

        });

    }

    // GET faq list elements from category link
    $.fn.getFaqList = function() {

        $.get($(this[0]).attr('href'), function(data) {

            base.addFaqSectionToPage( $(data).find('section.faq-page #content-column') );

        });

    };

    // add new faq section to current page
    this.addFaqSectionToPage = function(faqSection) {

        // remove old faq section
        var currentFaqSection = $('section.faq-page #content-column');

        currentFaqSection.empty();
        currentFaqSection.append(faqSection);

    };

};

$.testAjaxFilter();

When viewing the console by clicking on one of the category links, GET retrieves the entire page in its response, but it is followed by a syntax error, an unrecognized expression: (lists all the HTML from the extracted page). So, in $.fn.getFaqListsomething wrong, maybe use $(data)?

Is there something obvious I'm doing wrong? Any help would be greatly appreciated. I am not very good at AJAX stuff.

+5
source share
2 answers

Thanks to Musa for this. I would reward you for the correct answer ... but I think I can not do this for comment :(

:

$(data).find

:

$($.parseHTML(data)).find

- , Stackoverflow, , . , , :

JQuery Ajax

jQuery + = " , "

+10

:

if ( typeof currentFaqCategories !== 'undefined') {

:

if ( typeof currentFaqCategories != 'undefined') {
0