Note that there are some explanatory texts on larger screens.

plurals
  1. POXMLHttpRequest stalls on send() if I attempt to pass an encoded URL containing an ampersand
    primarykey
    data
    text
    <p>I'm making an Ajax call that sends a URL to a PHP script. Oftentimes these URLs are complex and contain special characters. If I <em>don't</em> encode the URL before sending, the PHP script works, but the URL's values are interpreted as my values (which is expected).</p> <p>If I <em>do</em> encode a URL that <em>doesn't</em> contain special characters, like '<a href="http://google.com" rel="nofollow">http://google.com</a>' for example, the XMLHttpRequest sends my parameters to my PHP script as expected and everything works fine.</p> <p>The issue is when I encode a URL that <em>does</em> contain special characters, like '<a href="http://google.com?this=that&amp;that=this" rel="nofollow">http://google.com?this=that&amp;that=this</a>' -- send() doesn't ever reach my PHP script. It just hangs indefinitely. No errors or anything. I'm stumped.</p> <p>Here's what I'm working with:</p> <pre><code>function getContent(content, sumbittedUrl){ var postContent = encodeURIComponent(content); var postUrl = encodeURIComponent(submittedUrl); var postString = 'content=' + postContent + '&amp;url_get=' + postUrl; var httpRequest; //create XMLHttpRequest . . . httpRequest.onreadystatechange = alertContents; httpRequest.open('POST', 'php/my_php_script.php', true); httpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); httpRequest.send(postString); } </code></pre> <p>I'm a JavaScript novice so it's possible (likely, even) that I overlooked something that someone with more experience would spot quickly. Any help would be appreciated. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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