/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
post.html: <script type="text/javascript" language="javascript"> function makePOSTRequest(url, parameters) { if (window.XMLHttpRequest) { // Mozilla, Safari,... // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { } catch (e) { try { } catch (e) {} } } alert('Cannot create XMLHTTP instance'); return false; } } function alertContents() { //alert(http_request.responseText); document.getElementById('myspan').innerHTML = result; } else { alert('There was a problem with the request.'); } } } function get(obj) { var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) + "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value ); makePOSTRequest('post.php', poststr); } </script> <form action="javascript:get(document.getElementById('myform'));" name="myform" id="myform"> <textarea id="mytextarea1">my test 1 2 3
URL: http://www.captain.at/howto-ajax-form-post-request.php