通过调用aspx文件和使用Web服务有什么区别 [英] what difference by calling an aspx file and consuming a webservice
问题描述
使用web服务和调用aspx文件有什么区别。
在这个例子中,当调用Default2.aspx文件时,它正在工作但是在使用Web服务CarService.asmx时它会引发错误:
未知的Web方法SaveData。参数名称:methodName
你可以看到我已经注释掉了调用webservice var query =CarService.asmx / SaveData;因为它在取消注释时引发了上面提到的错误。 />
这是我的代码:
what is the difference between consuming a webservice and calling aspx file.
In this exemple when calling an Default2.aspx file it is working but when consuming a webservice CarService.asmx it is raising an error:
Unknown web method SaveData. Parameter name: methodName
As u can see I have comment it out the calling of the webservice var query = "CarService.asmx/SaveData";because it it raising the error mentioned above when uncomment.
This is my code:
$(function () {
var checkin = $("#datepickercheckin").val();
var checkout = $("#datepickercheckout").val();
$('#btnSearchAvailRoom').on("click", function () {
Greating();
});
});
function Greating() {
var query = "Default2.aspx/SaveData";
//var query = "CarService.asmx/SaveData";
$.ajax({
type: "POST",
contentType: "application/json;charset=utf-8",
url: query,
data: '{ checkindate: "'+ checkin + '", checkoutdate: "'+ checkout +'" }',
dataType: "json",
success: function (data) {
$('#divtxt').text(data.d);
},
error: function (result) {
alert("error");
}
});
}
我在两个文件webservice或aspx.cs文件中使用相同的代码,在后面的代码中:
and I am using the same code for both files webservice or the aspx.cs file, in the code behind:
[WebMethod]
public static string SaveData(string checkindate, string checkoutdate)
{
string str = checkindate + " " + checkoutdate;
return str;
}
你能告诉我差异吗?为什么我得到那个错误以及如何解决它
can u tell me the difference and Why I am getting that error and how to resolve it
推荐答案
(function(){
var checkin =
(function () { var checkin =
(#datepickercheckin)。val();
var checkout =
("#datepickercheckin").val(); var checkout =
(#datepickercheckout)。val();
("#datepickercheckout").val();
这篇关于通过调用aspx文件和使用Web服务有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!