【发布时间】:2021-04-13 00:15:27
【问题描述】:
我正在使用 Visual Studio 2015 中的 apache cordova 工具开发一个 android 应用程序。我想从我在 cordova 应用程序中的索引页面调用一个 Web 服务,但我无法实现它。
这里是 HTML
<div ><input type="button" id="callwebmethod" name="submit" /> <br /> </div>
这里是JS函数
<script type="text/javascript">
$('#callwebmethod').click(function () {
var params = "{'msg':'From Client'}";
$.ajax({
type: "POST",
url: "http://mysite/index.aspx/GetEmployees",
data: params,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) { alert(result.d); }
});
})
</script>
这是网络方法
[WebMethod]
public static string GetEmployees()
{
return "Hello World";
}
【问题讨论】:
标签: android web-services cordova visual-studio-2015 apache-cordova