Why can't I access my WCF web service with Javascript?

后端 未结 2 812
眼角桃花
眼角桃花 2020-12-22 04:57

I\'m new at AJAX and I\'m trying to access a WCF web service the following way:

$(function () {
    $(\'#formNew\').submit(function () {
        var datos =          


        
2条回答
  •  情书的邮戳
    2020-12-22 05:33

    The JSON.stringify(data) use is to convert a javascript object to json representation.

    I think that in the success\error functions you need to go the other way:

     success: function (data) {
                                alert("Exito " + JSON.parse(data));
                              },
     error:   function (data) {
                                alert("Error " + JSON.parse(data));
                              }
    

    (when using JSON.parse, JSON.stringify - make sure you included the json2.min.js in your project)

提交回复
热议问题