Wednesday, 15 June 2011

javascript - How to send the array to querystring -


Friends, I need help to send an array for query string. Just a simple HTML page

  var obj = []; Obj [0] = {Guest: "Ramkumar", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Obj [1] = {Guest: "Satish", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Obj [2] = {Guest: "Suresh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Obj [3] = {Guest: "Ganesh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Var x = JSON.stringify (obj); Window.location = "view.html?form =" + JSON.stingify (obj);  

I got this kind of error while redirecting .. Internal server error.

  var obj = []; Obj [0] = {Guest: "Ramkumar", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Obj [1] = {Guest: "Satish", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Obj [2] = {Guest: "Suresh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Obj [3] = {Guest: "Ganesh", City: "Madurai", Mobile: "9578606320", Email: "bsrsms@gmail.com", Address: "First Road"}; Var x = JSON.stringify (obj); Window.location = "view.html?form =" + JSON.stingify (obj);  

There is an error in it.

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

should be

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

JSON Not JSON Scolding

Your server side is probably not expecting faulty outputs of your code.

Edit

As mentioned in the comments, you have already converted your object variable into X, so it's going to string any No need again. That's why you

  window.location = "view.html? Object =" + x; Can also be used.  

No comments:

Post a Comment