标签:
var phoneAgent = navigator.userAgent; var urlDomaintest = " ";
function getHref() { var href = window.location.href; return href; } var PhoneAgent=
$(function () {
$.ajax({
async: false,
url: urlDomaintest + "Home/CloudUserInfo",
type: ‘GET‘,
data: { UserName: phoneAgent, UserEmail: getHref() },
dataType: "jsonp",
jsonp: "callback",
success: function (data) {
console.log("success");
if (data.Status==1)
{
var docSpan = document.getElementById("NumSpan");
docSpan.innerHTML = data.ResultNum;
}
else
{
var docSpan = document.getElementById("NumSpan");
docSpan.innerHTML = "3500";
}
}
})
});
public ActionResult CloudUserInfo(string callback, string UserName, string UserEmail)
{
AjaxResult<string> jsonResult = new AjaxResult<string> { Status = -1, ResultNum = 0, Data = "" };
try
{
ApplicationDbContext dbContext = new ApplicationDbContext();
CloudQaUser cuInfo = new CloudQaUser();
cuInfo.UserEmail = UserEmail;
cuInfo.UserName = UserName;
cuInfo.CreateTime = DateTime.Now;
dbContext.CUerInfo.Add(cuInfo);
if (dbContext.SaveChanges() > 0)
{
//发邮件
jsonResult.Status = 1;
SendGuRuEmail(cuInfo.UserEmail);
}
}
catch (Exception ex)
{
jsonResult.Status = 0;
}
//return Json(jsonResult, JsonRequestBehavior.AllowGet);
return JavaScript(string.Format("{0}({1});", callback, Newtonsoft.Json.JsonConvert.SerializeObject(jsonResult)));
}
标签:
原文地址:http://www.cnblogs.com/hanxingli/p/5407549.html