I'm writing a browser extension. In main.html recorded input.
<br> </br> <input id="fileInput" type="file" size="50" onchange="onFilesSelect(event)"> <div id="fileOutput"></div> <br> </br> in main.js I have a code like this
(function($){ function ajaxStart(){ $('#progress').show(); } function ajaxStop(){ $('#progress').hide(); } function parserGo(){ ajaxStart(); var mask=$('input#inputer').val(); var site=$('input#inputSite').val(); var b = $.ajax('https://www.google.ru/search?q= '+mask+' '+site); //Парсинг //..... } $(function(){ $('#progress').hide(); $('#starter').click(parserGo); }); })(jQuery); As you can see the parsing begins with the click of a button. Before parsing, I need to select a file in which I will enter information. I add it to any place in the main.js code
function onFilesSelect(e) { alert("Loaded"); } no reaction after selecting a file. What am I doing wrong?
That's what I found in the networks ...
var filesExt = ['jpg', 'gif', 'png', 'htm']; // массив расширений $('input[type=file]').change(function(){ var parts = $(this).val().split('.'); if(filesExt.join().search(parts[parts.length - 1]) != -1){ alert('Good!'); } else { alert('WTF?!'); } }) Earned, now I want to get the text from the file. How now to pull out the inside of the file selected in the input?