本文介绍了webservice和jquary.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为当前日期和时间制作了一个Web服务....为此,我制作了一个用于调用此代码的网页.
网络服务........
i have made one web service for current date and time....and for that i have made one web page for calling this the code islook like.
webservice........
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace learningajax
{
/// <summary>
/// Summary description for getdate
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class getdate : System.Web.Services.WebService
{
public getdate()
{
}
[WebMethod]
public string getdatetime()
{
return DateTime.Now.ToString();
}
}
}
网页.............
webpage.............
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dateandtime.aspx.cs" Inherits="learningajax.dateandtime" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="button1" type="button" value="Get Date And Time" />
<br />
<br />
<span id="output" />
</div>
</form>
<script src="Scripts/purvang.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
$.ajax({
type: "POST",
url: "/ASPNET_WebServices_JQuery/DateWebService.asmx/GetDateTime",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$("#output").text(msg.d);
}
});
});
});
</script>
</body>
</html>
这里的脚本purvang.js是1.7.2.js脚本,但是我没有得到任何输出结果,这是什么解决方案?
here the script purvang.js is 1.7.2.js script but i got nothing as output what is solution?
推荐答案
这篇关于webservice和jquary.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!