0

I have a jQuery program that calls a web service via AJAX. Please see the code in the question I asked earlier:

<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>

I discovered after reading the following question that you cannot make cross domain calls using jQuery without applying a setting, which I have now done.

How do you specify the AJAX URL. The following both error:

http://mypc/Service1.svc/HelloWorld
http://mypc/Service1.svc\HelloWorld

HelloWorld is the function that I want to call contained in the web service. HelloWorld returns an integer.

Community
  • 1
  • 1
w0051977
  • 15,099
  • 32
  • 152
  • 329

0 Answers0