mohamadmahmodi
سه شنبه 13 مرداد 1394, 17:02 عصر
سلام به همه اساتید
این کد HTML من هستش:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="content/js/jquery-2.1.4.js"></script>
<title></title>
</head>
<body>
<script type="text/javascript">
$("document").ready(
$.ajax(
{
type: "POST",
url: "test.asmx/sending",
data:"'st:','sultan'",
contentType: "application/json",
dataType: "json",
success: accessfn,
error: errfn
}
)
)
function accessfn(result) {
alert(result.d);
}
function errfn(result) {
alert(result.d);
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/test.asmx" />
</Services>
</asp:ScriptManager>
</form>
</body>
</html>
و این هم کد .asmx:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
namespace didantest
{
/// <summary>
/// Summary description for didan
/// </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 didan : System.Web.Services.WebService
{
[ScriptMethod]
[WebMethod]
public string sending(string st)
{
st = st + "bingo";
return st;
}
}
}
اما نتیجه result.d برابر "undefined" هست.
چرا این کار نمیکنه و مشکل کجاست؟
تشکر از همه:تشویق:
این کد HTML من هستش:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="content/js/jquery-2.1.4.js"></script>
<title></title>
</head>
<body>
<script type="text/javascript">
$("document").ready(
$.ajax(
{
type: "POST",
url: "test.asmx/sending",
data:"'st:','sultan'",
contentType: "application/json",
dataType: "json",
success: accessfn,
error: errfn
}
)
)
function accessfn(result) {
alert(result.d);
}
function errfn(result) {
alert(result.d);
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/test.asmx" />
</Services>
</asp:ScriptManager>
</form>
</body>
</html>
و این هم کد .asmx:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
namespace didantest
{
/// <summary>
/// Summary description for didan
/// </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 didan : System.Web.Services.WebService
{
[ScriptMethod]
[WebMethod]
public string sending(string st)
{
st = st + "bingo";
return st;
}
}
}
اما نتیجه result.d برابر "undefined" هست.
چرا این کار نمیکنه و مشکل کجاست؟
تشکر از همه:تشویق: