Ajax calls in symfony framework
<p>I wanna make ajax calls in symfony2. I already done with ajax with flat php and  i have no idea how to set up in this symfony framework. </p>

<pre><code>    &lt;html&gt;
    &lt;head&gt;
    &lt;script&gt;
    function showBook(str) {
        if (str == "") {
            document.getElementById("txtHint").innerHTML = "";
            return;
        } else { 
            if (window.XMLHttpRequest) {
                // code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            } else {
                // code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                    document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                }
            };
            xmlhttp.open("GET","getuser.php?q="+str,true);
            xmlhttp.send();
        }
    }
    function showAuthor(str){
        if (str == "") {
            document.getElementById("txtHint").innerHTML = "";
            return;
        } else { 
            if (window.XMLHttpRequest) {
                // code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            } else {
                // code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                    document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                }
            };
            xmlhttp.open("GET","getAuthor.php?q="+str,true);
            xmlhttp.send();
        }
    }
    &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;

    &lt;form action=""&gt; 
    Book name: &lt;input type="text" id="txt1" onkeyup="showBook(this.value)"&gt;
    &lt;br&gt;&lt;br&gt;
    Author name:&lt;input type="text" id="txt1" onkeyup="showAuthor(this.value)"&gt;
    &lt;/form&gt;
    &lt;br&gt;
    &lt;div id="txtHint"&gt;&lt;b&gt;book info will be listed here...&lt;/b&gt;&lt;/div&gt;

    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>Where should i pass this request?? to controller?? 
how to set routes??
is there any way to use flat php instead of controller??</p>