var url="http://fsa.citop.in/lnct/service/signProcess.aspx";
var data={txtLogId: "[email protected]",txtLogPass: "xyz",hdnReqType2: "sign87162"};
var success=function(data, textStatus, jqXHR) {
console.log(data);
};
var fail=function(jqXHR, textStatus, errorThrown) {
console.log("Error:" + errorThrown);
}
$.ajax({
type: "POST",
url: url,
data:data,
success:success,
error:fail,
});
該POST請求給我的錯誤,SyntaxError: Unexpected token < in JSON at position 4
,在鍍鉻的頁面「http://fsa.citop.in/lnct/」的控制檯。意外標記<在JSON在第4位
但是,如果我使用fsa.citop.in/lnct/service/signProcess.aspx
(即沒有http://),它沒有給我任何錯誤,但沒有數據返回。在POST請求的success
上,預計會有JSON對象。請有人解釋這裏發生的事情以及如何解決。
你在成功回調中使用了'JSON.parse(data)'嗎?你會得到同樣的錯誤,因爲函數需要一個字符串。 – Irshu