JS备忘录

1.获取地址栏

function getUrlParam(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //获取本页面匹配目标参数
    if (r!=null) return unescape(r[2]); return null; //返回参数值
}

function getUrlParam(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.top.location.search.substr(1).match(reg);  //获取上层页面匹配目标参数
    if (r!=null) return unescape(r[2]); return null; //返回参数值
}

2.调取后台文件

  $.ajax({

url: "/MetaPortlet/EPP/CanderNote/Resources/CanderNote.asmx/InsertCanderNote",
beforeSend: function (x) { x.setRequestHeader("Content-Type", "application/json; charset=utf-8"); },
data: "{logid:'" + logid + "',starttime:'" + startDateObj.Format("yyyy-MM-dd hh:mm:ss") + "',endtime:'" + endDateObj.Format("yyyy-MM-dd hh:mm:ss") + "',note:'" + what + "'}",
dataType: 'json',
cache: false,
async: true,
type: 'POST',
error: function (x, e) {
alert("失败");
},
success: function (data) {
// add new event to the calendar
jfcalplugin.addAgendaItem(
"#mycal",
what,
startDateObj,
endDateObj,
false,
{
myNum: logid
},
{
backgroundColor: $("#colorBackground").val(),
foregroundColor: $("#colorForeground").val()
}
)

}
});

posted @ 2015-10-26 17:54  大漠孤侠  阅读(308)  评论(0编辑  收藏  举报