0
我知道這已被問過很多次,但在閱讀所有解決方案後,我仍然無法找到解決此問題的方法。我從最近4個小時就停留在這一點上,所以任何幫助都會真正被讚賞。 這裏是我的Ajax調用:無效的Web服務調用,參數缺失值:'newReviewOrLike'
$.ajax({
url: "http://localhost:1316/MoviesWebService.asmx/saveReview",
data: '{ username:"kartik1990",critic:"sanjayR",quote:"great",imdbId:"tt189",isCriticAMember:"true",reviewOrLikes:"review" }',
type: 'post',
contentType: 'application/json',
dataType:'json',
success: function (response) {
console.log(response);
}
});
ASMX代碼:
[WebMethod]
public bool saveReview(ProjLikesTO newReviewOrLike) {
using (kkapilaCSDataContext db = new kkapilaCSDataContext()) {
proj_like action = new proj_like();
action.username = newReviewOrLike.username;
action.critic = newReviewOrLike.critic;
action.quote = newReviewOrLike.quote;
action.imdbId = newReviewOrLike.imdbId;
action.isCriticAMember = newReviewOrLike.isCriticAMember;
action.reviewOrlikes = newReviewOrLike.reviewOrLikes;
db.proj_likes.InsertOnSubmit(action);
db.SubmitChanges();
return true;
}
ProjLikesTO:
public class ProjLikesTO {
public string username {
set;
get;
}
public string critic {
set;
get;
}
public string quote {
set;
get;
}
public string imdbId {
set;
get;
}
public string isCriticAMember {
set;
get;
}
public string reviewOrLikes {
set;
get;
}
public ProjLikesTO() {
}
public ProjLikesTO(string username, string critic, string quote, string imdbId, string isCriticAMember, string reviewOrLikes) {
this.username = username;
this.critic = critic;
this.quote = quote;
this.imdbId = imdbId;
this.isCriticAMember = isCriticAMember;
this.reviewOrLikes = reviewOrLikes;
}
}
它的工作..!非常感謝。 – user3291389
我的榮幸@ user3291389 :) – Neel