Jump to content

javasscript escape function removes backslash when saving from code editor


calabiyau

Recommended Posts

I am building my own framework and have used "editarea" as my online code editor.  I use ajax to open and save files from the server.  everything is working properly, except one thing.  I discovered that in order to get the save to work I had to use the javascript escape() function before sending the post request to the server, otherwise the & symbols in the code messed up the post request.  Now the problem is if the code contains something like this:

 

$server_path = "C:\server\apache\www";

 

When it saves the file, it comes out like this:

 

$server_path = "C:serverapachewww";

 

I do a strip slashes on the php receiving end before saving the file to get rid of the escapes created by the javascript end, and through alerts discovered that that is not the problem.  They are being eliminated before the ajax request is sent.  Anybody have any ideas on how to resolve this problem?  Am I using the wrong approach?

Link to comment
Share on other sites

Okay my mistake, on further investigation, the ajax side was okay, needed html_entity_dedode on the php side to convert the characters back.  Everything works great now.  For anyone who isn't clear on the relationships between ajax and php, this website has a neat little gadget that explains how they all relate

 

http://www.the-art-of-web.com/javascript/escape/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.