Run javascript from jQuery.ajax call
<p>I am learning jQuery, so I'm attempting to write this simple demo. I've tried a variety of approaches and I've done searching here and elsewhere before resorting to posting this question.</p>

<p>I understand that $.ajax makes an xmlhttpRequest, which I am familiar with. That being the case, I thought it would work if I sent that to a PHP file where I could compute my result. Unfortunately, when I open tryjquery.html in my browser, the page just displays the word "error" in my "div" block. Thanks in advance for the assistance.</p>

<p>Here's my code:</p>

<p>In tryjquery.html, I have a script section that calls this:</p>

<pre><code>Calculator.addRemote(1,5,function(result){
$('div').html(result);
});
</code></pre>

<p>Calculator is this object:</p>

<pre><code>function Calculator(){
this.addRemote = addRemote;
}

that = Calculator;
that.addRemote = function (a, b, completedHandler){

var post = $.ajax({
    url: "/Calculator/Add",
    data: {a: a, b: b},
    type: "POST"
});

   post.done(function (result) {
   completedHandler(result);  
   });  

   post.fail(function () {  
   completedHandler('error');  
   });  
}
</code></pre>

<p>...and /Calculator/Add is this php code:</p>

<pre><code>&lt;?php
$a = $_GET['a'];
$b = $_GET['b'];
$r = $a + $b;
echo "result=".$r.";";
?&gt;
</code></pre>
