代码如下:
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>湖南</title> <meta name="description" content="Default Description" /> <meta name="keywords" content="Magento, Varien, E-commerce" /> <meta name="robots" content="INDEX,FOLLOW" /> <script type="text/javascript" src="http://gsxt.hnaic.gov.cn/notice/js/jquery.min.js?t=20160122-01"></script> </head> <body> <script language="javascript" type="text/javascript"> <!-- var ajaxCommon = function(opt, callback) { // 默认ajax选项 var options = { dataType: "text", data: {}, ansyc: true, type: "POST", contentType: "application/x-www-form-urlencoded", cache: true }; // 获取ajax选项 $.extend(options, opt); $.ajax({ url: options.url, data: options.data, dataType: options.dataType, ansyc: options.ansyc, type: options.type, contentType: options.contentType, cache: options.cache, complete: function(jqXHR, textStatus) { // 获取ajax返回的信息 var result = jqXHR.responseText; alert(result); // 获取信息时系统出现意外错误 if(typeof result == "undefined" || jqXHR.state() != "resolved") { // 弹出错误提示 // 结束调用 return false; } // 调用回调函数,以ajax返回的信息为参数 if(typeof callback == "function") { callback(result); } } }); }; $(document).ready(function(){ var global = global || {}; // 当前令牌对象 global.token = { name: "session.token", code: "3f3e367f-ade7-40b8-aa3e-29b8fb120fee", data: { "session.token": "3f3e367f-ade7-40b8-aa3e-29b8fb120fee" } }; var cpt = cpt || {}; cpt.verify = function(captcha, scb, ecb) { ajaxCommon({ url: "http://gsxt.hnaic.gov.cn/notice/security/verify_captcha", data: $.extend({ captcha: captcha }, global.token.data) }, function(result) { if(result == constants.yes) { // 校验通过回调函数 if(typeof scb == "function") { scb(); } } else { ecb(); } }); }; cpt.verify(0, function(){alert(‘1‘)},function(){alert(‘2‘)}) }); --> </script> </body> </html>
出现bug。已拦截跨源请求:同源策略禁止读取位于 http://gsxt.hnaic.gov.cn/notice/security/verify_captcha 的远程资源。(原因:CORS 头缺少 ‘Access-Control-Allow-Origin‘)。
时间: 2024-11-05 06:27:45