What I'm trying to do is use the below javascript
to pull a php
page into my html
. This works, but what I need and struggling to do is use javascript
to send a variable to php
so I can use mysql
to send results back.
httpRequest("garage-view-default.php", showdefaultimage);
function showdefaultimage(WIDGET){
d = document.getElementById('garage-view-default');
d.innerHTML = WIDGET;
}
function httpRequest(url, callback) {
var httpObj = false;
if (typeof XMLHttpRequest != 'undefined') {
httpObj = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try{
httpObj = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {try{
httpObj = new ActiveXObject('iMicrosoft.XMLHTTP');
} catch(e) {}
}
}
if (!httpObj) return;
httpObj.onreadystatechange = function() {
if (httpObj.readyState == 4) { // when request is complete
callback(httpObj.responseText);
}
};
httpObj.open('GET', url, true);
httpObj.send(null);
}