I am trying to create an AJAX Call to a webservice but nothing happens. I want to put a number in an input box submit it to the webservice, calculate it and submit it back to another input box.
$(document).ready(function() {
$('#Num').change(function(){
$.ajax({
type: "GET",
url: "test5handler.ashx",
data: { Num: $('#Num').val() },
error: {alert("Something went wrong")},
success: function(msg){
$('#resultNum').val(msg);
}
});
});
});
<form id="form1" runat="server">
<div>
Please enter a Number:
<input type="text" id="Num">
<br />
<input type="text" id="resultNum">
</div>
</form>
public class test5handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string Num = context.Request.QueryString["Num"];
Double adjNum = Double.Parse(Num);
Double Total = (adjNum*5);
context.Response.Write(Total);
}
public bool IsReusable
{
get
{
return false;
}
}
}