这个代码用不了 哪位大神帮帮忙啊

发布于 2014/09/25 12:46
阅读 169
收藏 0

var courseId = getCookie("COURSEID");

if (courseId == null) {

console.log("搜索URL...");

courseId = getUrl("courseId");

}

 

if (courseId == null) {

throw "未找到课程ID,可能当前窗口不是观看课程页面";

}

var playTime = 2000000;

studyCheck();

//updateTime();

//saveNormal();

 

function getCookie(name) {

var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");

if (arr = document.cookie.match(reg))

return unescape(arr[2]);

else

return null;

}

 

function getUrl(name) {

var arr, reg = new RegExp(name + "=([^&]*)");

if (arr = window.location.href.match(reg))

return unescape(arr[1]);

else

return null;

}

 

function studyCheck(){

var request = new XMLHttpRequest();

var url = "../../../../../../els/html/coursestudyrecord/coursestudyrecord.studyCheck.do?courseId="+courseId;

 

request.open("GET", url, true);

request.setRequestHeader("X-Requested-With", "XMLHttpRequest");

request.setRequestHeader("Accept",

"text/javascript, text/html, application/xml, text/xml, */*");

request.setRequestHeader("Content-Type",

"application/x-www-form-urlencoded; charset=UTF-8");

request.onreadystatechange = function() {

if (request.readyState == 4) {

console.log(request.responseText);


saveNormal();

}

};

request.send();

}

 

function updateTime(){

var request = new XMLHttpRequest();

var url = "../../../../../../els//html/study/study.updateTimestepByUserTimmer.do";

var esid=getCookie("eln_session_id");

if(esid==null){

throw "请在正确的页面使用!";

}

var data = "elsSign=" + esid;

request.open("POST", url, true);

request.setRequestHeader("X-Requested-With", "XMLHttpRequest");

request.setRequestHeader("Accept",

"text/javascript, text/html, application/xml, text/xml, */*");

request.setRequestHeader("Content-Type",

"application/x-www-form-urlencoded; charset=UTF-8");

request.onreadystatechange = function() {

if (request.readyState == 4) {

console.log(request.responseText);

if(request.responseText!="\"true\""){

throw "更新时间错误!"+request.responseText;

}

saveNormal();

}

};

request.send(data);

}

 

function saveNormal() {

var request = new XMLHttpRequest();

var url = "../../../../../../els/html/coursebasic/coursebasic.saveCoursePrecent.do";

var data = "courseId=" + courseId

+ "&playTime=" + playTime;

request.open("POST", url, true);

request.setRequestHeader("X-Requested-With", "XMLHttpRequest");

request.setRequestHeader("Accept",

"text/javascript, text/html, application/xml, text/xml, */*");

request.setRequestHeader("Content-type",

"application/x-www-form-urlencoded; charset=UTF-8");

request.onreadystatechange = function() {

if (request.readyState == 4) {

console.log(request.responseText);

console.log("刷新课程列表,看看课程[" + courseId + "]是否已经100%");

}

};

request.send(data);

}

回车后就出现 SyntaxError: Unexpected identifier

加载中
返回顶部
顶部