How do I get these two functions to work with Ajax, and how to I rewrite it in Jquery?
<pre><code>function ajaxFunction(phpFunction){
    var ajaxRequest;  // The variable that makes Ajax possible!

    try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        // Internet Explorer Browsers
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
    $('.subCat').html(ajaxRequest.responseText);
    $('.subCat').ready(function(){
    $('.subCat').fadeIn();
    });





        }
    }


    var url = "products.php?func=" + phpFunction;

    ajaxRequest.open("GET", url, true);
    ajaxRequest.send(null); 

}
</code></pre>

<p>This function works great, and has no problems. But if I add:</p>

<pre><code>function refreshProduct(idNum, phpFunction){
    var ajaxRequest;  // The variable that makes Ajax possible!

    try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        // Internet Explorer Browsers
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
        $('.' + idNum).empty();
    $('.' + idNum).html(ajaxRequest.responseText);

    });





        }
    }


    var url = "products.php?func=" + phpFunction + "&amp;idNum=" + idNum;

    ajaxRequest.open("GET", url, true);
    ajaxRequest.send(null); 

}
</code></pre>

<p>When I try to execute <code>ajaxFunction('returnAllProducts')</code> I get:             </p>

<pre><code>    syntax error
 });\n
</code></pre>

<p>from</p>

<pre><code>   $('.' + idNum).html(ajaxRequest.responseText);

    }); &lt;&lt;&lt;----
</code></pre>

<p>and</p>

<pre><code>ajaxFunction is not defined
javascript:ajaxFunction('returnAllProducts')()
</code></pre>

<p>So my questions are:</p>

<p><strong>a)</strong> how do I convert this over to jquery? I've read over some jquery ajax tutorials, but I wasn't able to make the connection how to do what I am doing here.
<strong>b)</strong> How do I get both functions to work? I know the PHP behind them works fine, but I can't even test if <code>refreshProduct()</code> works properly right now.</p>
