我正在通过.ajax().调用javascript文件中的php函数
我有
$.ajax({
url: templateDir + 'functions.php',
async : false,
data: "function=images",
success: function (response) {
alert(response);
}
});
如果response
返回为字符串someObject.someMethod();
,我希望解析并运行该字符串。我可以console.log或提醒它,但我无法概念化如何运行返回的字符串。
如果你不知道的话,我是jquery和ajax的新手。
使用eval
:
success: function (response) {
eval(response);
}