-
Notifications
You must be signed in to change notification settings - Fork 0
Ajax function
Rayhan Uddin edited this page Jun 2, 2017
·
1 revision
function createXHR()
{
var xhr;
if (window.ActiveXObject)
{
try
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
alert(e.message);
xhr = null;
}
}
else
{
xhr = new XMLHttpRequest();
}
return xhr;
}
To implement 🔢
var xhr = createXHR();
xhr.onreadystatechange = function()
{
if (xhr.readyState === 4)
{
alert(xhr.responseText);
}
}
xhr.open('GET', 'test.txt', true)
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.send()
or
var param = {id:1};
xhr.send(param)