JS 代码
$.ajax({
type : "POST",
contentType : "application/json",
url : "/WebService/MoveScanWebService.asmx/MoveSave",
data : "{ data:'" + parmsjson + "' }",
dataType : 'json',
success : function(result) {
var arr = result.d.split(':');
if (arr[1] == "success") {
$("#errorMsg").html("");
window.location.href = "SelDM.ashx?operateType=move&location="
+ parmtxtDesLocation
+ "&stackid="
+ $("#txtStackid").val() + "&MoveParmsV=" + parmsVmove;
} else {
$("#errorMsg").html(arr[1]);
}
}
});
C#代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using TerminalWeb.Dto;
using TerminalWeb.Service;
using System.Collections;
namespace TerminalWeb.WebService
{
/// <summary>
/// CheckScanWebService 的摘要说明
/// </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 CheckScanWebService : System.Web.Services.WebService
{
#region CheckScanService
private CheckScanService m_CheckScanService;
private CheckScanService CheckScanService
{
get
{
if (this.m_CheckScanService == null)
this.m_CheckScanService = new CheckScanService();
return this.m_CheckScanService;
}
}
#endregion
[WebMethod]
public CheckStockInfo GetCheckStockInfo(string cargono, string location)
{
location = location.ToUpperInvariant();
return this.CheckScanService.GetCheckStockInfo(cargono.Trim(),location.Trim());
}
[WebMethod]
public string CheckSave(string data)
{
string[] myparms = data.Split(',');
Hashtable table = new Hashtable();
foreach (string parm in myparms)
{
string[] dat = parm.Split(':');
table.Add(dat[0], dat[1]);
}
String msg = "";
this.CheckScanService.SaveCheck(table, ref msg);
if (msg.Equals(""))
{
msg = "success";
}
return msg;
}
}
}