TypeError: data.forEach is not a function

前端 未结 5 1543
孤街浪徒
孤街浪徒 2021-01-18 06:38

This is my code:

$.ajax({
    url: \"some_url/\",
    type: \"GET\",
    dataType: \"json\",
    success: function(data){
        console.log(data);
                 


        
5条回答
  •  暖寄归人
    2021-01-18 07:29

    It is a case where your data response looks like an array but it is a string. If you have access to the API you're connecting to you can ensure the response it sends out is an array but if not simply parsing the data response using JSON.parse() should do the trick.

提交回复
热议问题