jquery ajax 一直error

bshedu bshedu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

function ok() {

var mes= $("#txtOpin").val(); ;
$.ajax({
url: "backGroundService.asmx/saveOpinion",
dataType: "text",
data: "mes",
contentType: "application/json; charset=utf-8",
success: function (msg) { //msg就是方法返回值
//这里是请求成功做的操作
alert(msg);
},
error: function (xhr, msg, e) {
//这里是失败了
alert(msg);
}


后台c#



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;


namespace XJNWeb.template
{
/// <summary>
/// backGroundService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class backGroundService : System.Web.Services.WebService
{

public static string saveOpinion(string mes)
{
if (mes == "")
{
return "请填写意见";
}
else
{

return "保存成功";
}

}



...全文
评论 24
收藏 已收藏
分享
返回顶部
bshedu
.NET社区 62,272 成员 668,968 内容