I'm using Ratchet 2 to build an app. I'm trying to make a simple ajax call and get the response like so
function tryLogin() {
var hxr;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.open("POST", "absolutePathToMyScript");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
var obj = JSON.parse(xhr.responseText);
console.log(obj);
//spinner.classList.remove("active");
}
}
var data = {
login: document.querySelector('#loginForm input[name="login"]').value,
pwd: document.querySelector('#loginForm input[name="pwd"]').value
};
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("login=" + data.login + "&pwd=" + data.pwd);
}
When I click on my button that fire tryLogin()
the ajax call is well executed but the page is reloaded.
I assume that it is from push.js
Is there any solution to ignore push.js on an ajax call ?