x1nick Posted August 9, 2009 Share Posted August 9, 2009 Im trying to make a textarea with a button which saves the document (via php) now I can get the script to post the textarea's content's so I can process it with PHP but it dosen't seem to post it EXACTLY as displayed Here is the javascript function ajaxpost (url,poststr,divid) { xmlhttp = GetXmlHttpObject(); if (xmlhttp == null) { alert ("Browser does not support HTTP Request"); return; } xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4) { handleresponse(xmlhttp.responseText,divid); } } xmlhttp.open('POST', url, true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", poststr.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(poststr); } function handleresponse(response,divid) { document.getElementById(divid).innerHTML = response; } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } The code thats run onclick of the button savebutton.onclick = function () { var code = "tplcode=" + escape(self.mirror.getCode()); ajaxpost('index.php?acms&s=ajax&amod=tpl&ajax=save&tplid=<?=$_REQUEST['tplid']?>',code,'messagearea'); }; Now this appears to work ok besides one problem + symbols. sbox.style.top = (realoffset(searchfield,"offsetTop")+searchfield.offsetHeight-1)+"px"; Which comes out like this sbox.style.top = (realoffset(searchfield,"offsetTop") searchfield.offsetHeight-1) "px"; As you can see its missed out the + from the code thats been submitted within the text area. Is the problem caused by var code = "tplcode=" + escape(self.mirror.getCode()); and how do I resolve this? Quote Link to comment Share on other sites More sharing options...
student101 Posted August 24, 2009 Share Posted August 24, 2009 http://www.aleixcortadellas.com/main/2009/03/01/ajax-post/ 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.