<script type="text/javascript">
function ajaxsubmit(name,phone) {
$.ajax({
type: "get",
url: "http://10.10.10.132:35709/AppInterface/ResourceInsert.ashx",
data: { "share_name": encodeURI(name), "telphone": encodeURI(phone), "fromtype": 4 },
dataType : "jsonp",
jsonp: "callback",
jsonpCallback: "successcallback",
success: function (json) {
alert(json.msg);
},
error:function(e){
alert("提交失败!请稍后再试");
}
});
}
</script>
public class ResourceInsert : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
cms.Model.Resource model = new Model.Resource();
cms.BLL.Resource bll = new BLL.Resource();
//你所需要进行的操作
model.share_name = HttpUtility.UrlDecode(context.Request["share_name"]);
model.ask_telphone = HttpUtility.UrlDecode(context.Request["telphone"]);
model.back_row_one = context.Request["fromtype"];
ConvertHelper ch = new ConvertHelper();
model.share_name = ch.RemoveSpecialChar(model.share_name);
//successcallback为跨域请求回调函数,切记必不可少。获取方式也可以为context.Request["callback"],
//对应前端页面发起请求的jsonp和jsonpCallback格式为:jsonp_value=jsonpCallback_value
if (bll.Exists(model.share_name, model.ask_telphone))
{
Message temp = new Message(1, "我们已收到您的请求额!请勿重复提交!", null);
context.Response.Write("successcallback" + "(" + JsonConvert.SerializeObject(temp) + ")");
context.Response.End();
return;
}
else
{
if (bll.Add(model) > 0)
{
Message temp = new Message(1, "提交成功,我们工作人员会尽快回复你!感谢关注!", null);
context.Response.Write("successcallback" + "(" + JsonConvert.SerializeObject(temp) + ")");
context.Response.End();
return;
}
else
{
Message temp = new Message(0, "请确认信息填写无误!", null);
context.Response.Write("successcallback" + "(" + JsonConvert.SerializeObject(temp) + ")");
context.Response.End();
return;
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/> <add name="Access-Control-Allow-Headers" value="x-requested-with,content-type"/> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> </httpProtocol> </system.webServer>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有