Closed Thread
Results 1 to 5 of 5

Thread: AJAX - Escaping (

  1. #1
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30

    AJAX - Escaping (

    I have JavaScript and PHP working together fairly well except for this one error.

    Code:
    <script>
    if value == 1
      document.write('$phpVariable');
    </script>
    Only the phpVariable has () in it so I get an error in my javascript - expecting ")". How do I escape the () in JavaScript?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    hoser2001's Avatar
    hoser2001 is offline Programmer
    Join Date
    Jul 2006
    Posts
    175
    Rep Power
    0
    This is just a guess...

    Code:
    <script>
    if value == 1
      document.write('$phpVariable\(\)');
    </script>

  4. #3
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    I don't understand this. What is the \(\) doing?

  5. #4
    hoser2001's Avatar
    hoser2001 is offline Programmer
    Join Date
    Jul 2006
    Posts
    175
    Rep Power
    0
    if you are attempting to write a string, and your string contains (
    then to escape that character would simply be \(

    if your variable is a string, then you need to change that variable so that those characters are escaped in this way. Perhaps before sending the variable to the write function you can someone search for those characters and precede them with the escape character \

  6. #5
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    Ahh, I never thought about doing that. I suppose when I started combining the two I felt limited in what I could do. Thanks!

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MySQL escaping
    By phillw in forum Database & Database Programming
    Replies: 1
    Last Post: 02-14-2010, 03:12 AM
  2. can php do this or do I need ajax?
    By jimiwa in forum PHP Development
    Replies: 3
    Last Post: 11-03-2009, 01:13 AM
  3. .Net and Ajax
    By smithcarvo in forum ASP, ASP.NET and Coldfusion
    Replies: 2
    Last Post: 08-29-2008, 02:39 AM
  4. Blocking GUI Movement escaping ur app
    By MXTECH in forum Visual Basic Tutorials
    Replies: 3
    Last Post: 07-02-2008, 08:48 PM
  5. AJAX - Escaping (
    By Lop in forum JavaScript and CSS
    Replies: 4
    Last Post: 08-18-2007, 06:01 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts