我正在使用來自Jquery ajax的Spring MVC調用。該呼叫擊中控制器,並將結果顯示在切換側。但是,在我的瀏覽器的代碼所示沒有什麼Jquery Ajax響應未顯示
$.ajax({
url: "http://localhost:8080/sample/sample-byName",
cache: false,
data:'firstName=' + $("#firstName").val() + "&lastName=" + $("#lastName").val() + "¤tCompany=" + $("#currentCompany").val(),
dataType:"text",
crossDomain : true,
ContentType:"text/html",
success: function(data){
alert(data);
},
error: function(e){
alert('Error while request..'+e);
}
});
當我通過螢火看到它說200 OK
。任何人都可以幫我嗎?
我控制器代碼是通過Ajax
public @ResponseBody String getLinkedInByName(HttpServletRequest request) {
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String currentCompany = request.getParameter("currentCompany");
String resultJson = client.getNameSearchWithHelpers(firstName,lastName,currentCompany);
System.out.println(resultJson);
return resultJson;
}
淨結果Allow GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH Content-Length 0 Date Tue, 16 Jul 2013 05:17:18 GMT Server Apache-Coyote/1.1
普通URL提交 Content-Length 640 Content-Type text/html Date Tue, 16 Jul 2013 05:14:21 GMT Server Apache-Coyote/1.1
只是一個側面說明,U可能拼錯'contentType'(注意第一個字母是小寫):) – krishgopinath
如果你可以在Firebug中看到響應代碼,你也可以看到響應。它是什麼? – 2013-07-16 03:52:24
對不起。它也不能解決我的問題 – jackyesind