php - xhr in chrome extension -
i have created small extension requires communicate php script on server side mysql activities.
the code used php connectivity works when used normal webpage when try access chrome extension, aint sure if getting called.
code:
document.addeventlistener('domcontentloaded', function() { var link = document.getelementbyid('signup_submit').submit(); // onclick's logic below: link.addeventlistener('click', function() { alert('jksd'); window.onload = function() { var xhr = new xmlhttprequest; var url = "http://localhost/browserextension/chrome%20extensions/register.php"; var username = document.getelementbyid('usrname').value; var dispname = document.getelementbyid('name').value; var password = document.getelementbyid('passwd').value; var params = "usrname=" + username + "&name=" + dispname + "&passwd=" + password; xhr.open("get", url, true); xhr.setrequestheader("content-type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function () { if (4 == this.readystate) { var status = this.status; if (400 > status) { var responsetext = this.responsetext; if (responsetext) { //document.getelementbyid('resultado').innerhtml = responsetext; alert(responsetext); } } } }; xhr.send(params); } }); });
Comments
Post a Comment