germs12 Posted December 6, 2006 Share Posted December 6, 2006 I am having an interesting error in my AJAX app...I am trying to take the contents of a rich text editor and send it to the server using an XMLHttpRequest via GET and save it to my MySQL database, then be able to retrieve it again and load it into my rich text editor. The problem is that my encoding and decoding is really messing my style tags up and I am losing all styles.Has anyone else experienced anything like this before? Does anyone know the correct encode/decode function to use? I am using Javascript on the client and PHP on the server. Any help would be great.Thanks. Quote Link to comment Share on other sites More sharing options...
ober Posted December 6, 2006 Share Posted December 6, 2006 Can you post some of the code? Quote Link to comment Share on other sites More sharing options...
germs12 Posted December 7, 2006 Author Share Posted December 7, 2006 OK....I take some html tags and in JS do encodeURIComponent. I then send it over to my PHP server, urlencode it and send it back and do a decodeURIComponent. I am losing half my html.Here is what I start with. <textarea cols="50" rows="10" id="normal_text" name="normal_text"></textarea><br> <textarea cols="50" rows="10" id="encoded" name="encoded"></textarea><br> <textarea cols="50" rows="10" id="rpc_response" name="rpc_response"></textarea><br>This is what it encoded to.%3Ctextarea%20cols%3D%2250%22%20rows%3D%2210%22%20id%3D%22normal_text%22%20name%3D%22normal_text%22%3E%3C%2Ftextarea%3E%3Cbr%3E%0A%09%3Ctextarea%20cols%3D%2250%22%20rows%3D%2210%22%20id%3D%22encoded%22%20name%3D%22encoded%22%3E%3C%2Ftextarea%3E%3Cbr%3E%0A%09%3Ctextarea%20cols%3D%2250%22%20rows%3D%2210%22%20id%3D%22rpc_response%22%20name%3D%22rpc_response%22%3E%3C%2Ftextarea%3E%3Cbr%3Eand this is what gets retuned.<textarea+cols=\"50\"+rows=\"10\"+id=\"normal_text\"+name=\"normal_text\">WTF? I lose half of my html. Any ideas? I would show you the site, but it is inward facing on campus, sorry. Quote Link to comment Share on other sites More sharing options...
ober Posted December 7, 2006 Share Posted December 7, 2006 Well, it would have helped if you showed us the JS code... but have you tried using POST instead of GET? (I'm only assuming that's the method you're using). You can pass more data in POST than GET and I think that may be the issue you're running into. Quote Link to comment Share on other sites More sharing options...
germs12 Posted December 7, 2006 Author Share Posted December 7, 2006 Thanks for the quick replies, but I figured it out. It was an issue where I was using innerHTML and not value when putting my results back onto the webpage.Senior Design Project is almost finished! 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.