如何使用jquery加载方法将文件的内容加载到变量中? [英] How to load the content of a file into variable using jquery load method?

查看:77
本文介绍了如何使用jquery加载方法将文件的内容加载到变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery .load()方法将文件的内容加载到变量而不是DOM中?

How do I load the content of a file into a variable instead of the DOM using jQuery .load() method?

例如,

$("#logList").load("logFile", function(response){ });

我希望将文件加载到变量中,而不是将文件加载到DOM的#logList元素中.

Instead of loading the file into the #logList element of the DOM, I would like it to load into a variable.

推荐答案

load()只是$.get的快捷方式,它自动将内容插入DOM元素,因此:

load() is just a shortcut for $.get that atuomagically inserts the content into a DOM element, so do:

$.get("logFile", function(response) {
     var logfile = response;
});

这篇关于如何使用jquery加载方法将文件的内容加载到变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆