Wasim A. Wasim A. - 2 months ago 17
Javascript Question

AJAX POST JSON Array Javascript NOT JQUERY

enter image description here

In this screenshot, a JSON array is being passed to PHP via AJAX without a POST body. I am using this code to implement it:

with(x=new XMLHttpRequest()) open("POST", "http://myweb/api/mobile/v1/jobeventadd?key=cfff"), setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), send("%7B%0A%22SessionID%22%3A%22hn0oqa0u687avsrnev6f5t2nh7%22%2C%0A%22ObjectID%22%3A%226460%22%2C%0A%22ItemName%22%3A%22UologiciPhone%20test%20event%22%2C%0A%22ActivityFrom%22%3A%2201-01-2013%2012%3A00%3A00%22%0A%7D");


But it's not working. How can I do it via XMLHttpRequest? No JQUERY PLEASE

Answer

It was same as GET

with(new XMLHttpRequest)
  {
  open("POST","http://google.com",true);
  send("hello=world&no=yes");
  onreadystatechange = function(){};
  }