ANT Interview Questions and Answers
Ques. How to Generate/Send JSON Data at the Client Side?Ans. • Create JSON JavaScript object• Use \"POST\" HTTP method in the open method of the XMLHttpRequest object • Pass JSON JavaScript object in the send method of XMLHttpRequest object var carAsJSON = JSON.stringify(car); var url = \"JSONExample?timeStamp=\" + new Date().getTime(); createXMLHttpRequest(); xmlHttp.open(\"POST\", url, true); xmlHttp.onreadystatechange = handleStateChange; xmlHttp.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\"); xmlHttp.send(carAsJSON); |
Is it helpful?
Yes
No
Most helpful rated by users: