Skip to content

Instantly share code, notes, and snippets.

@diorahman
Created March 2, 2012 09:03
Show Gist options
  • Save diorahman/1957020 to your computer and use it in GitHub Desktop.
Save diorahman/1957020 to your computer and use it in GitHub Desktop.
XMLHttpRequest POST
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("POST","http://localhost:8080/send/action",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send('params={"session": "123", "token":"HE7qkv8lGaK2Mht684m79bJkT3", "action":"joborders", "mode" : "dev", "params":{"app":{"os":"harmattan", "qt": "4_7_4", "name" : "Campur Sari", "version": "0.0.1", "color":["green", "#d1d2d3","#f0f1f3"], "feedViewType": "Grid", "feeds": "Gamasutra News=http://feeds.feedburner.com/GamasutraNews, Gamasutra Feature Articles=http://feeds.feedburner.com/GamasutraFeatureArticles"}}}');
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">Request data</button>
<div id="myDiv"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment