How to send variable to php from javascript and return the result back to JS
<p>I have this code.</p>

<pre><code>var book = document.getElementById('txtBook').value;
switch(book.toUpperCase())
    {
        case "GEN": var bk = "101"; break;
        case "EXO": var bk = "101"; break;
        case "LEV": var bk = "101"; break;
        case "DEU": var bk = "102"; break;
        ... and so on...
    }
</code></pre>

<p>I want to replace my <code>switch</code> with a database query. Since I learn from searching here that I can't do it straight from JS, I need to pass it to php Variable.</p>

<p>I want to know how to pass my <code>var book</code> to a php page like for example getbook.php</p>

<p>I will then make a query on php side. I want that result back to my JS for further processing.</p>

<p>I prefer method with no page refresh required.</p>

<p>Thanks</p>
