javascript 中的eval问题 javascript 中的eval里不能包含AJAX这个单词吗包括了就会出错JS中还有没有和EVAL这个函数有一样的功能了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的json格式不正确吧,怎么可能不能包含ajaxvar s="{ajax:'内容',AJAX:'AJAX'}"var o=eval('('+s+')')//========注意加上括号()alert(o.ajax)alert(o.AJAX)s='["ajax","AJAX","AJAX"]'o=eval('('+s+')')alert(o) function smileqAjax(url){ var m_xmlReq=false; var m_OnSucceed=function(){}; var m_OnReading=function(){}; var m_timer=null; this.Url=url; if(window.XMLHttpRequest) { m_xmlReq = new XMLHttpRequest(); } else if(window.ActiveXObject) { try {m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP'); }catch(e) { try { m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');}catch(e){} } } this.OnReading = function(reading) { m_OnReading = reading; } this.OnSucceed=function(succeed) { m_OnSucceed=succeed; } this.OnTimeout=function(timeout) { m_timer=window.setTimeout(timeout,10000); } this.invokeServer = function(send_data, method) { if (!m_xmlReq) return; var thisUrl = this.Url; if (this.Url.indexOf("?") > 0) thisUrl += "&r=" + (new Date()).getMilliseconds() + "&" + send_data.toString(); else thisUrl += "?r=" + (new Date()).getMilliseconds() + "&" + send_data.toString(); m_xmlReq.open(method, thisUrl, true); if (method == 'POST') m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8'); m_xmlReq.onreadystatechange = function() { if (m_xmlReq.readyState == 1) { m_OnReading(); } else if (m_xmlReq.readyState == 4 && m_xmlReq.status == 200) { var result = null; if (m_xmlReq.responseText != "") { // result = m_xmlReq.responseText; // document.write(m_xmlReq.responseText); eval("result=" + m_xmlReq.responseText); } m_OnSucceed(result); if (m_timer != null) window.clearTimeout(m_timer); } } m_xmlReq.send(''); }} 这是我的代码 function smileqAjax(url){ var m_xmlReq=false; var m_OnSucceed=function(){}; var m_OnReading=function(){}; var m_timer=null; this.Url=url; if(window.XMLHttpRequest) { m_xmlReq = new XMLHttpRequest(); } else if(window.ActiveXObject) { try {m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP'); }catch(e) { try { m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');}catch(e){} } } this.OnReading = function(reading) { m_OnReading = reading; } this.OnSucceed=function(succeed) { m_OnSucceed=succeed; } this.OnTimeout=function(timeout) { m_timer=window.setTimeout(timeout,10000); } this.invokeServer = function(send_data, method) { if (!m_xmlReq) return; var thisUrl = this.Url; if (this.Url.indexOf("?") > 0) thisUrl += "&r=" + (new Date()).getMilliseconds() + "&" + send_data.toString(); else thisUrl += "?r=" + (new Date()).getMilliseconds() + "&" + send_data.toString(); m_xmlReq.open(method, thisUrl, true); if (method == 'POST') m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8'); m_xmlReq.onreadystatechange = function() { if (m_xmlReq.readyState == 1) { m_OnReading(); } else if (m_xmlReq.readyState == 4 && m_xmlReq.status == 200) { var result = null; if (m_xmlReq.responseText != "") { // result = m_xmlReq.responseText; // document.write(m_xmlReq.responseText); eval("result=" + m_xmlReq.responseText); } m_OnSucceed(result); if (m_timer != null) window.clearTimeout(m_timer); } } m_xmlReq.send(''); }} 这是我的代码 m_xmlReq.responseText返回的内容是什么?? eval("alert('aaa')")相当于执行alert('aaa'),你的能执行吗? 关于document.write中引用函数,其中函数参数的问题 帮我看看下面代码哪错了::: 关于获取父窗体表单的问题 JavaScript.DOM编程艺术 哪位有中文版的 刷新窗口问题 烦恼! asp 使用javascript写的,想从数据库里库里读出图片显示在网页上怎么做?急! 请教一个问题,请大家帮帮忙。 请大家帮我看看这个PRO有什么问题!谢 求详细的身份证验证js kendo treeview 获取父节点值的问题 鼠标经过select option 时,能否把option里的内容以提示形式显示出来 extjs editorGridPanel 保存数据问题..
var o=eval('('+s+')')//========注意加上括号()
alert(o.ajax)
alert(o.AJAX)
s='["ajax","AJAX","AJAX"]'
o=eval('('+s+')')
alert(o)
{
var m_xmlReq=false;
var m_OnSucceed=function(){};
var m_OnReading=function(){};
var m_timer=null; this.Url=url; if(window.XMLHttpRequest)
{
m_xmlReq = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
try {m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP'); }catch(e)
{
try { m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
}
} this.OnReading = function(reading) {
m_OnReading = reading;
} this.OnSucceed=function(succeed)
{
m_OnSucceed=succeed;
} this.OnTimeout=function(timeout)
{
m_timer=window.setTimeout(timeout,10000);
} this.invokeServer = function(send_data, method) {
if (!m_xmlReq) return;
var thisUrl = this.Url;
if (this.Url.indexOf("?") > 0)
thisUrl += "&r=" + (new Date()).getMilliseconds() + "&" + send_data.toString();
else
thisUrl += "?r=" + (new Date()).getMilliseconds() + "&" + send_data.toString();
m_xmlReq.open(method, thisUrl, true);
if (method == 'POST')
m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
m_xmlReq.onreadystatechange = function() {
if (m_xmlReq.readyState == 1) {
m_OnReading();
}
else if (m_xmlReq.readyState == 4 && m_xmlReq.status == 200) {
var result = null;
if (m_xmlReq.responseText != "") {
// result = m_xmlReq.responseText;
// document.write(m_xmlReq.responseText);
eval("result=" + m_xmlReq.responseText);
}
m_OnSucceed(result);
if (m_timer != null) window.clearTimeout(m_timer);
}
}
m_xmlReq.send('');
}
} 这是我的代码
{
var m_xmlReq=false;
var m_OnSucceed=function(){};
var m_OnReading=function(){};
var m_timer=null; this.Url=url; if(window.XMLHttpRequest)
{
m_xmlReq = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
try {m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP'); }catch(e)
{
try { m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
}
} this.OnReading = function(reading) {
m_OnReading = reading;
} this.OnSucceed=function(succeed)
{
m_OnSucceed=succeed;
} this.OnTimeout=function(timeout)
{
m_timer=window.setTimeout(timeout,10000);
} this.invokeServer = function(send_data, method) {
if (!m_xmlReq) return;
var thisUrl = this.Url;
if (this.Url.indexOf("?") > 0)
thisUrl += "&r=" + (new Date()).getMilliseconds() + "&" + send_data.toString();
else
thisUrl += "?r=" + (new Date()).getMilliseconds() + "&" + send_data.toString();
m_xmlReq.open(method, thisUrl, true);
if (method == 'POST')
m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
m_xmlReq.onreadystatechange = function() {
if (m_xmlReq.readyState == 1) {
m_OnReading();
}
else if (m_xmlReq.readyState == 4 && m_xmlReq.status == 200) {
var result = null;
if (m_xmlReq.responseText != "") {
// result = m_xmlReq.responseText;
// document.write(m_xmlReq.responseText);
eval("result=" + m_xmlReq.responseText);
}
m_OnSucceed(result);
if (m_timer != null) window.clearTimeout(m_timer);
}
}
m_xmlReq.send('');
}
} 这是我的代码