gpt4 book ai didi

javascript - 使用 Ajax 传递解析 JSON 值时出错

转载 作者:行者123 更新时间:2023-12-03 04:04:55 24 4
gpt4 key购买 nike

这是我的 Ajax 调用

<script>
$.ajax({
url:"http://localhost:3000/house/get-all",
type: "GET",
dataType: 'json',
data,
crossDomain: "true",

}
});
</script>

这是我的 html 代码:

<div id="houses">
This is place to put content. You can put slider, short description about your website and place some links for navigation.
</p>
</div>

错误:

Uncaught ReferenceError: data is not defined

最佳答案

如果您没有在 ajax 选项中传递任何数据,则不需要数据:

$.ajax({
url:"http://localhost:3000/house/get-all",
type: "GET",
dataType: 'json',
// data, -- remove this or pass something here
// ...
});

关于javascript - 使用 Ajax 传递解析 JSON 值时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44605286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com