我有兩個API方法,他們都與AJAX jquery調用完美工作,但是當我從android Http代碼調用這兩個方法,第一種方法工作完美的,其他第二不從調用jQuery的從Android手機調用基於JSON的ASP.NET網絡服務
$.ajax({
type: "POST",
url: 'websiteaddress/Accounts/Login',
data: '{username: "test" , password: "test" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) { alert(success);},
error: function (reponse) { alert(reponse);}
});
AC工作
從調用jQuery的$.ajax({
type: "POST",
url: 'websiteaddress/Accounts/Login?username=test&password=test',
data: '',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) { alert(success);},
error: function (reponse) { alert(reponse);}
});
第2種方法的例子
第1種方法的例子其實我的問題是與android有關,但我分享了jquery調用,因爲它的代碼尺寸小於android :)
調用的主要區別是第一個發送數據與URL和第二個與正文。
希望你明白我的問題。任何建議將不勝感激。 我會分享android代碼,如果需要的話。
感謝
你讀到問題結束:)?我要求的Android代碼將採取參數不在URL或Querystring –