JQuery: .hide () is not a valid function

Firebug complains about this line:

$("#original-description").text(response['course']['original_description']).hide();

Do I have a syntax error? It looks good to me.

More context:

bindOnSuccess($('#course-search'), function(response) {
    if (!response) {
        $("#system-status").text("Sorry, no course could be found for that search.");
    }
    else {
        $(".dept-code").text(response['course']['dept_code']);
        $(".course-number").text(response['course']['number']);
        $(".course-title").text(response['course']['title']);

        $("#div-original-description").show();
        $("#original-description-teaser").show();

                    // error here
        $("#original-description").text(response['course']['original_description']).hide();

        $("#td-required-for").text(response['analysis']['cRequiredFor']);
    }
});

response- The JSON object. Could this issue be due to invalid indexes?

Firebug Error:

$("#original-description").text(response.course.original_description).hide is not a function
+3
source share
1 answer

Other answers indicate incorrectly - .text()returns jQuery object. You are probably referring to the undefined property. I can reproduce this:

$('<p>').text(undefined).hide()

Make sure you reference the right property in JSON.

 TypeError: $("<p>").text(undefined).hide is not a function { message="$("<p>").text(undefined).hide is not a function",  more...}

If you want to request a live object, you can simply do

window.o = response in your callback function and just play with it in the Firebug console.

+4
source

Source: https://habr.com/ru/post/1750953/


All Articles