Please see the code below:
<script type='text/javascript'>
$(document).ready(function () {
$("button").click(function(){
alert('Test');
$('#div1 h2').text('Hi I am replace');
var divToBeWorkedOn = "#div1";
var n1 = 1;
var n2 = 2;
var webMethod = "Service1.svc/getNumber";
$.ajax({
type: "POST",
url: webMethod,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
$(divToBeWorkedOn).html(val(result));
},
error: function (e) {
$(divToBeWorkedOn).html(e.responseText);
}
});
})
});
</script>
Here is the code from the server side:
Public Function getNumber() As Integer Implements IService1.GetNumber
Return 1
End Function
The div1 contains no text after I click the button. I think it is calling the web service because it did error when I named it Service.svc/getNumber by mistake. What am I doing worng?