Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your code <em>as quoted</em> is fine (I've tried it locally).</p> <p>My guess is that the <code>formParams</code> string in your question is just an example, and in reality you're doing something to generate that string on the fly, and the problem lies in <em>that</em> code instead.</p> <p>For instance, are you sure you're escaping characters correctly (using <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent" rel="nofollow"><code>encodeURIComponent</code></a>)? Or better yet, let jQuery deal with it, like this:</p> <pre><code>$.ajax({ type: 'POST', url: '/foo.jsp', async: false, data: { fe1: $("#somefield1").val(), fe2: $("#somefield2").val(), fe3: $("#somefield3").val() }, complete: function(xmlRequestObject, successString){ ymmReceiveAjaxResponse(xmlRequestObject, successString); } }); </code></pre> <p>If you pass in an object, jQuery will handle the URI-encoding for you. If you <em>really</em> want to do it yourself:</p> <pre><code>var formParams = "fe1=" + encodeURIComponent($("#somefield1").val()) + "fe2=" + encodeURIComponent($("#somefield2").val()) + "fe3=" + encodeURIComponent($("#somefield3").val()); $.ajax({ type: 'POST', url: '/foo.jsp', async: false, data: formParams, complete: function(xmlRequestObject, successString){ ymmReceiveAjaxResponse(xmlRequestObject, successString); } }); </code></pre> <p>There I haven't encoded the field names because those names don't have any special chars in them; you need to if your form names are more interesting than that.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload