jQuery中的Ajax评估和演示response.d [英] Eval response.d in Jquery Ajax
本文介绍了jQuery中的Ajax评估和演示response.d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是这样做的一点:
VAR resultsArray =(typeof运算response.d)=='串'
?的eval('('+ response.d +')'):response.d;
里面的onSuccess()回调$的。(AJAX)调用?
解决方案
VAR resultsArray = / *赋值给resultsArray ... * /
(typeof运算response.d)=='串'? / * ...如果response.d的类型是串* /
的eval((+ response.d +')')/ * ...然后评估它,仿佛它是JS code * /
response.d; / * ...其他人只是为它分配不变* /
What is the point of doing this:
var resultsArray = (typeof response.d) == 'string'
? eval('(' + response.d + ')') : response.d;
inside onSuccess() callback of $.(ajax) call?
解决方案
var resultsArray = /* assign a value to resultsArray... */
(typeof response.d) == 'string' ? /* ...if the type of response.d is string */
eval('(' + response.d + ')') : /* ...then evaluate it as if it was JS code */
response.d; /* ...else just assign it unaltered */
这篇关于jQuery中的Ajax评估和演示response.d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文