jQuery .find() on data from .ajax() call is returning “[object Object]” instead of div

前端 未结 17 1335
一生所求
一生所求 2020-12-07 22:05

Trying to find div element with id=\"result\" in returned data from .ajax() using .find(). Unfortunately, alert(res

17条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 22:50

    Specify dataType: "html".

    If you do not jQuery will guess the requested data type (check: http://api.jquery.com/jQuery.ajax/). My guess is that in your case response was a String rather than a DOMObject. Obviously DOM methods won't work on a String.

    You could test that with console.log("type of response: " + typeof response) (or alert("type of response:" + typeof response), in case you don't run Firebug)

提交回复
热议问题