Hello everybody,
I guess my main question is; How do i encode HTML data from a textarea to prepare it for an AJAX call ( post method ).
I'm trying to insert some html code in a record in my database via a ajax http request. I'm using the POST method. The html that i'm trying to insert is in a textarea ( CKEDITOR: WYSIWYG ) and it seems to be working. But when i change some mark-up in the textarea, like making a word Strong. The AJAX functions returns a 403 Forbidden page.
I don't understand this because there are also <p></p> surrounding the data but that doesn't give an error. Only if i change to mark-up some more and add more HTML to the data then the AJAX call gives the 403 response page.
What is the best way to solve this problem. Must i encode all data before the AJAX call?.
This is my code.
Code:var p = "hiddenSEOID="+document.editProductForm.hiddenSEOID.value; p += "&productSEOID="+document.editProductForm.productSEOID.value.toLowerCase(); p += (document.editProductForm.prodAlive.checked) ? "&prodAlive=1" :"&prodAlive=0" ; p += "&prodName="+document.editProductForm.prodName.value; p += "&prodRange="+document.editProductForm.prodRange.value; p += "&prodDesc="+CKEDITOR.instances.prodDesc.getData(); p += "&categories="+EL.compile("categoriesEL"); p += "&prodKeywords="+EL.compile("keywordsEL"); alert(p); var xhr = xmlHttpRequest(); xhr.open("POST","php/updateProductBySEOID.php", true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-length", p.length); xhr.setRequestHeader("Connection", "close"); xhr.onreadystatechange = function(){ if(xhr.readyState==4){ alert(xhr.responseText); } } xhr.send(p);


Reply With Quote
Bookmarks