aximbigfan Posted March 18, 2008 Share Posted March 18, 2008 YES, I have tried the AJAX forum. It is not active. I have an HTML page, with a text box. When something is in that textbox, and the user hits submit, I want the data to be POSTED to a PHP page, and have the PHP return the doctored data. I have the PHP part down, it's just the javascript part I am having trouble with. The text boxes name is "string", and the form name is just "form". Can someone please tell me why this doesn't work before I pull my hair out Ignore the content of the params, I only put that in to see if it wasn't something else messing up. It should use document.form.NAME.value. function ajax() { var xmlhttp; try { xmlhttp=new XMLHttpRequest(); } catch (e) { try { xmlhttp=new ActiveXObject(\"Msxml2.XMLHTTP\"); } catch (e) { try { xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\"); } catch (e) { alert(\"No AJAX support!\"); return false; } } } return xmlhttp; } var http = ajax(); var url = \"index.php\"; var params = \"mode=rot13&string=test\"; function handler() { if (http.readystate==4 && http.status==200) { document.form.string.value = http.responceText; } } function post() { http.open(\"POST\", \"index.php\", true); http.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\"); http.setRequestHeader(\"Content-length\", params.length); http.setRequestHeader(\"Connection\", \"close\"); http.onreadystatechange = handler; http.send(params); } Please, please help!! Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/96657-ajax-post-data-and-put-result-in-text-box/ Share on other sites More sharing options...
GB_001 Posted March 19, 2008 Share Posted March 19, 2008 Use getelementbyid on the form to target it with AJAX. Link to comment https://forums.phpfreaks.com/topic/96657-ajax-post-data-and-put-result-in-text-box/#findComment-496406 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.