错误JQuery ajax调用 - 无效的Web服务调用,缺少参数值 [英] error JQuery ajax call - Invalid web service call, missing value for parameter
本文介绍了错误JQuery ajax调用 - 无效的Web服务调用,缺少参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi,
I am getting this error when passing parameter to an ajax call
This is my html page:
script type="text/javascript" type="text/javascript">
$(function () {
$("#theList").removeData();
$("#btnSearchAvailRoom").on("click", function () {
Greating();
});
});
function Greating() {
var checkin =$("#datepickercheckin").val();
var checkout = $("#datepickercheckout").val();
var query = "CarService.asmx/GetAllProducts";
$.ajax({
type: "POST",
url: query,
data: JSON.stringify({ checkindate: checkin, checkoutdate: checkout }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var productt = response.d;
alert(data);
$.each(productt, function (index, product) {
$("#theList").append(" " + product.name + " " + product.descr + "");
});
console.log(response);
},
error: function (response) {
$("#theList").append("error");
console.log(response);
}
});
}
</script>
</head>
<body>
<div>
<fieldset>
<legend>Search Room</legend>
<fieldset>
<legend>Show By </legend>
<p>
Checkin:
<input type="text" id="datepickercheckin" class="datepicker" />
</p>
<p>
Checkout:
<input type="text" id="datepickercheckout" class="datepicker" />
</p>
</fieldset>
<br /><input type="button" id="btnSearchAvailRoom" value="Search Room" />
</fieldset>
</div>
<div data-role="content">
<ul id="theList" data-role="listview" data-inset="true" data-filter="true">
</ul>
</div>
</body>
</html>
And this the code behind my webservice CarService.cs:
public List<product> GetAllProducts(string Checkin, string Checkout)
{
List<product> lstproducts = new List<product>();
DateTime CheckinDate = DateTime.ParseExact(Checkin, "mm/dd/yyyy", CultureInfo.InvariantCulture.DateTimeFormat);
DateTime CheckoutDate = DateTime.ParseExact(Checkout, "mm/dd/yyyy", CultureInfo.InvariantCulture.DateTimeFormat);
using (SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), "GetProducts", CheckinDate, CheckoutDate))
{
if (dr.HasRows)
{
while (dr.Read())
{
product _product = new product();
_product.name = Convert.ToString(dr["name"]);
_product.img = Convert.ToString(dr["Image"]);
_product.descr = Convert.ToString(dr["Description"]);
lstproducts.Add(_product);
}
}
return lstproducts;
}
}
Can you help what is wrong?
推荐答案
(function(){
(function () {
(#theList)。removeData();
("#theList").removeData();
(#btnSearchAvailRoom)。on(click,function(){
Greating();
});
});
函数Greating(){
var checkin =
("#btnSearchAvailRoom").on("click", function () { Greating(); }); }); function Greating() { var checkin =
这篇关于错误JQuery ajax调用 - 无效的Web服务调用,缺少参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文