我想在fetch命令中传递这些参数,以便将这些信息保存在数据库中
function addItemToCart(title,price,imgSrc)
{
console.log('starting ajax call')
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("http://127.0.0.1:5000/query?product=title", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}
如果在变量和字符串之间插入
+
,则可以向字符串添加变量。所以你不会这么做:然后,您可以使用以下代码行解析结果:
希望这有帮助
请记住,在执行args.get时,字符串应该是url中的“变量”,因此如果要查找id,则应该说
www.url.com?id=15
,但如果需要,可以使用任何单词代替id相关问题 更多 >
编程相关推荐