bob_the _builder Posted June 29, 2009 Share Posted June 29, 2009 Hi, Using: <form name="record" method="get" onSubmit="AjaxRequest("main","./includes/billing.php?action=records");"> to the following javascript for ajax: function AjaxRequest(target_div,file,check_div) { var MyHttpRequest = false; var MyHttpLoading = '<table width="100%" border="0" bgcolor="#FFFFFF" height="209"><tr><td align="center" valign="middle"><img src="./loading.gif"></td></tr></table>'; var ErrorMSG = 'Sorry - No XMLHTTP support in your browser, buy a newspaper instead'; if(check_div) { var check_value = document.getElementById(check_div).value; } else { var check_value = ''; } if(window.XMLHttpRequest) { try { MyHttpRequest = new XMLHttpRequest(); } catch(e) { MyHttpRequest = false; } } else if(window.ActiveXObject) { try { MyHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { MyHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { MyHttpRequest = false; } } } else { MyHttpRequest = false; } if(MyHttpRequest) { var random = Math.random() * Date.parse(new Date()); var file_array = file.split('.'); if(file_array[1] == 'php') { var query_string = '?rand=' + random; } else if(file_array[1] == 'htm' || file_array[1] == 'html') { var query_string = ''; } else { var query_string = check_value + '&rand=' + random; } MyHttpRequest.open("get", url_encode(file + query_string), true); MyHttpRequest.onreadystatechange = function () { if(MyHttpRequest.readyState == 4) { document.getElementById(target_div).innerHTML = MyHttpRequest.responseText; } else { document.getElementById(target_div).innerHTML = MyHttpLoading; } } MyHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); MyHttpRequest.send(null); } else { document.getElementById(target_div).innerHTML = ErrorMSG; } } But it doesnt seem to work, how can I submit a form to it using GET method? Thanks Link to comment https://forums.phpfreaks.com/topic/164083-submiting-form-using-get/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.