Invalid escape in identifier php
<p>I have the below PHP code to generate a table that has a click-able image embedded in one of the columns. I know that the function works because if just <code>sortleads()</code> is called on click, the JavaScript function is properly called. I attempted to escape the single quotes around <code>?sort=IDD</code> but I get the following error <code>SyntaxError: Invalid escape in identifier: '\'</code> in my JavaScript console. I've also tried double backslashing to escape the backslashes but that gives a similar error. How should I properly escape the single quotes? I've also included all relevant code.</p>

<p><strong>Relevant PHP excerpt:</strong></p>

<pre><code>$display_string .= "&lt;th&gt;ID &lt;img src='img/down.png' alt='down arrow' 
onclick= 'sortLeads(\'?sort=IDD\')' height='50px' width='50px'&gt; &lt;/th&gt;";
</code></pre>

<p><strong>Full PHP:</strong></p>

<pre><code>$display_string = "&lt;table class='table table-bordered table-hover scroller'&gt;";
$display_string .= "&lt;thead class='thead-inverse'&gt;";
$display_string .= "&lt;tr&gt;";
$display_string .= "&lt;th&gt;ID &lt;img src='img/down.png' alt='down arrow' onclick= 'sortLeads(\'?sort=IDD\')' height='50px' width='50px'&gt;
&lt;/th&gt;";
display_string .= "&lt;/tr&gt;";
$display_string .= "&lt;/thead&gt;";
$display_string .= "&lt;tbody&gt;";
</code></pre>

<p><strong>Javascript:</strong></p>

<pre><code>&lt;script language="javascript" type = "text/javascript"&gt;
function sortLeads(query) 
{
    var request = new XMLHttpRequest();
    request.onreadystatechange = function()
    {
        if (request.readyState == 4)
        {
            var results = document.getElementById('sortLeads');
            results.innerHTML = request.responseText;
        }
    }
    request.open("GET", "sortLeads.php"+query, true);
    request.send(null);
}
&lt;/script&gt;
</code></pre>