0

Short question, I am sending ajax request after pressing a button. A string might contain & and if it does, everything after & is treated as a name of second parameter. I tried to use encodeURI(string) but it did not work. How to handle this properly?

My code without experiments:

   <input class="refreshButton" type="button" value="refresh" onclick="$('#container').load('/some/path', {string: $('#string').val()});"/></td>

Cheers

mkk
  • 7,583
  • 7
  • 46
  • 62
  • That shouldn't happen. Since you are passing an object as the second argument, it should be escaped automatically. – Quentin Dec 17 '11 at 23:00
  • @Quentin well it happens, when I check the requests which is being sent, there are two parameters as well – mkk Dec 17 '11 at 23:04

1 Answers1

0

Don't Try the escape() function:

$('#container').load('/some/path', {string: escape($('#string').val())})

e: Whoops

SpoonNZ
  • 3,780
  • 1
  • 20
  • 25