0

我正在尝试使用 AJAX CALL 调用我的 Web 服务。但是我在我的萤火虫工具中遇到了不支持的媒体类型错误。

但它在 Rest-client Jar 中运行良好。下面是我的代码。

            $.ajax({
                type: "POST", //GET or POST or PUT or DELETE verb
                url: "http://localhost:8888/taxi/add/driver", // Location of the service
                data: {"firstName":"ttt","lastName":"gggg","gender":null}, //Data sent to server                            
               //contentType: "application/json", // content type sent to server
                //dataType: "json", //Expected data format from server
                //processdata: true, //True or False
                success: function (json) {//On Successfull service call
                    //shell.loaded();
                    alert("cross domain ajax success full.");

                   var result = json.firstName;

                    //alert("result===" + json.length);
                    //alert("result===" + json.data.length);
                    alert("result===" + result);
                    $("#dvAjax").html(result);
                },
                error: ServiceFailed// When Service call fails
            });


            return false;
        });



    });

    function ServiceFailed(xhr) {
        alert(xhr.responseText);
        //if (xhr.responseText) {
           // var err = xhr.responseText;
            //if (err)
               // error(err);
            //else
                error({ Message: "Unknown server error." })
        //}
        return;
    }

请指出我犯的错误在哪里。提前致谢。

问候卡西克

4

1 回答 1

0

你得到什么错误?响应来自哪里?它是成功还是错误
你应该指定dataType:'json'

于 2013-01-10T10:35:42.820 回答