i am using the following AJAX request method. Most of you probably use this script allready as it seems to be everywhere online. I use it often with out issue… until now.
What I’m finding is that if the click used to initiate the onblur() used like
[code]<input type=”text” id=”qty” name=”qty” value=”” onblur=”makeRequest(‘ajax_insert.php?field_name=qty&field_value=’,this.value);”>
is on either a link or from submit button, the onblur() never gets called. In my code, the onblur() has to work if the user goes strait for the submit button before clicking anywhere else.
Any ideas on how to get it to call onblur() and refresh in a one click process? Thanks much for the help.
My AJAX code
[code]
function makeRequest(url, parameters) {
http_request = false;
if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch (e) {
try {
http_request = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch (e) {}
}
} else if (window.XMLHttpRequest) { // Mozilla, Safari, Sometimes IE7…
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
http_request.overrideMimeType(‘text/xml’);
// http_request.overrideMimeType(‘text/html’);
}else{ alert(‘Did not create *http_request.overrideMimeType*’); return false; }
}
if (!http_request) {
alert(‘Cannot create XMLHTTP instance’);
return false;
}
http_request.onreadystatechange = alertContents;
// FOR POST VARS
//http_request.open(‘POST’, url, true);
//http_request.send(parameters);
// FOR GET VARS
//alert(url + parameters);
http_request.open(‘GET’, url + parameters, true);
http_request.send(null);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
document.getElementById(‘myspan’).innerHTML = result;
} else {
alert(‘There was a problem with the request.’);
}
}
}