glenelkins Posted August 29, 2008 Share Posted August 29, 2008 Hi I have no idea whats going on with this , but im not getting any response text back from my AJAX query. Iv setup the files with test data. In the response function iv set it to check for the word HELLO which is echoed from the actual PHP file, but nothing is coming back. Funny thing is this code works fine on another site iv worked on: AJAX functions // Http Object var http_request = false; function makePOSTRequest(url, parameters) { http_request = false; if ( window.XMLHttpRequest ) { // Mozilla, Safari,... 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 if ( window.ActiveXObject ) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if ( !http_request ) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = dovalidateregfields; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } function validate_reg_fields () { // Gather info var form = document.getElementById ( "regform" ); var first_name = form.first_name.value; var last_name = form.last_name.value; var email = form.email.value; var username = form.username.value; var password = form.password.value; var retypepassword = form.retypepassword.value; // Create ajax post string var poststr = "first_name=" + first_name + "&last_name=" + last_name + "&email=" + email + "&username=" + username + "&password=" + password + "&retypepassword=" + retypepassword; makePOSTRequest ( 'scripts/reg_form_validation.php', poststr ); } function dovalidateregfields() { if ( http_request.readyState == 4 ) { if ( http_request.responseText == "HELLO" ) { alert ( "HELLO" ); } } } scripts/reg_form_validation.php echo "HELLO"; Quote Link to comment Share on other sites More sharing options...
glenelkins Posted August 29, 2008 Author Share Posted August 29, 2008 this is actually only happening in FF. But it works on another website WIERD! Quote Link to comment Share on other sites More sharing options...
glenelkins Posted August 29, 2008 Author Share Posted August 29, 2008 I have changed the code ( below ) to be simpler. But im still not getitng response text from FF, IE is fine, its wierd iv never had this problem before <script language="javascript"> var http_object = false; function validate_reg_fields() { alert ( "Validating" ); var browser = navigator.appName; if( browser == "Microsoft Internet Explorer" ){ http_object = new ActiveXObject("Microsoft.XMLHTTP"); } else { http_object = new XMLHttpRequest(); } if ( http_object ) { alert ( "Object OK" ); http_object.onreadystatechange = function() { if ( http_object.readyState == 4 || http_object.readyState == "complete" ) { alert ( "Ready And Done" ); alert ( http_object.responseText ); } } http_object.open ( "GET", "scripts/reg_form_validation.php" ); http_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); http_object.send(null); } else { alert ( "Object Not Ok" ); } } </script> Quote Link to comment Share on other sites More sharing options...
glenelkins Posted August 29, 2008 Author Share Posted August 29, 2008 i figured it out for some reason in the php sending the response string back, firefox wont read it if you use: echo "kbkjbkjb"; but it will using echo ( "kbkjbj" ); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.