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? Link to comment https://forums.phpfreaks.com/topic/169471-problem-with-ajax-post/ 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/ Link to comment https://forums.phpfreaks.com/topic/169471-problem-with-ajax-post/#findComment-905291 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.