如何使用Ajax将文本文件内容上传到listBox [英] How to Upload Text File content to a listBox Using Ajax

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

问题描述

我想使用Jquery将一些逗号分隔的数字从文本文件上传到列表框,我不想在点击上传按钮时重新加载页面。



我想填充列表框中的所有内容。



文本文件内容示例:



123422234

243653718

353721838

354729839

263748239







123422234,243653718,353721838,354729839,263748239



真的会欣赏任何帮助谢谢...

I want to upload some comma separated numbers from a text file to a listbox using Jquery and i dont want the page to reloading when the upload button has been click.

I want to populate all the content inside the listbox.

Example of text file content:

123422234
243653718
353721838
354729839
263748239

OR

123422234, 243653718, 353721838, 354729839, 263748239

Will really Appreciate any help thanks...

推荐答案

在HTML5之前,如果不是不可能的话,它不是很容易,但是对于HTML5来说,这是非常好的前进。您可以使用HTML 5中的文件读取API在客户端本身执行此操作;



var reader = new FileReader();

FileReader。 readAsText(F); // f是用户在文件输入框中选择的文件。



详情请参阅以下文章;



使用文件API使用JavaScript读取文件
Its not very easy if not impossible with before HTML5, but with HTML5 it is pretty straigth forward. You can do that in client side itself using file read API in HTML 5;

var reader = new FileReader();
FileReader.readAsText(f); //f is a file selected by the user in the file input box.

Please refer to following article for detail;

Reading file with JavaScript using File API


这篇关于如何使用Ajax将文本文件内容上传到listBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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