gpt4 book ai didi

javascript - 如何将数组发送到查询字符串

转载 作者:行者123 更新时间:2023-12-03 10:33:45 26 4
gpt4 key购买 nike

Friends, i need the help for sending array to the querystring . just a simple html page.

var obj = [];
obj[0] = {Guest:"Ramkumar", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };
obj[1] = {Guest:"Sathish", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };
obj[2] = {Guest:"Suresh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };
obj[3] = {Guest:"Ganesh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };

var x = JSON.stringify(obj);


window.location = "view.html?Object=" + JSON.stingify(obj);

When redirect i got the error like this.. . Internal Server error.

最佳答案

var obj = [];
obj[0] = {Guest:"Ramkumar", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };
obj[1] = {Guest:"Sathish", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };
obj[2] = {Guest:"Suresh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };
obj[3] = {Guest:"Ganesh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address:"first street" };

var x = JSON.stringify(obj);


window.location = "view.html?Object=" + JSON.stingify(obj);

包含错误。

window.location = "view.html?Object=" + JSON.stingify(obj);

应该是

window.location = "view.html?Object=" + JSON.stringify(obj);

JSON.stringify,而不是 JSON.stingify

您的服务器端可能不希望代码输出错误。

编辑

正如评论中提到的,您已经将对象字符串化为变量 x,因此无需再次字符串化。因此您也可以使用

window.location = "view.html?Object=" + x;

关于javascript - 如何将数组发送到查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29098367/

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