WCF Web Service returns “Bad Request” error when invoked through Javascript

后端 未结 3 1743
悲哀的现实
悲哀的现实 2021-01-16 17:11

I am trying to make an ajax GET request to a WCF web service method through javascript. The request returns with a 400 \"Bad Request\" error everytime. But if I invoke the s

3条回答
  •  攒了一身酷
    2021-01-16 17:55

    I hope your service is running in another domain from where you are consuming it. You have to use JSONP calls in those cases.

    Modify the dataType to jsonp.

    $.ajax({
      //..
      dataType: "jsonp",
      //..
    });
    

提交回复
热议问题