Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

ANT%20Interview%20Questions%20and%20Answers

Question: How to Generate/Send JSON Data at the Client Side?
Answer: • 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:

©2024 WithoutBook