Search inside txt file using javascript

Malasorte

On www.example.com/page_a/ is it possible to run a javascript code that searches for the text "hello" inside the file located at www.example.com/page_b/my_file.txt ?

Is this possible with javascript/jquery/ any other javascript framework?

jacobdo

Yes, it is possible and it is simplest with jquery.

You need to "get" contents of the text file like this:

$.get("www.example.com/page_b/my_file.txt", function(contents){
   //contents variable now contains the contents of the textfile as string

   //check if file contains the word Hello
   var hasString = contents.includes("Hello");

   //outputs true if contained, else false
   console.log(hasString);
})

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Search for a double word inside .txt file using batch file

From Dev

BufferedReader - Search for string inside .txt file

From Dev

reading a txt file line by line using JavaScript

From Dev

How to search txt file from python using while loop

From Dev

Using "-t" option inside a requirements.txt file

From Dev

How to search for JavaScript variables in a file, using Python?

From Dev

How to search for a string inside an array elements using javascript?

From Dev

Optimize string search in .txt file

From Dev

How to search a txt file for regex?

From Dev

Load text from local .txt file into html textarea using JavaScript

From Dev

Reading data from txt file using javascript, every 5 min

From Dev

Is it possible to write text in .txt file using angularjs or javascript?

From Dev

search for Duplicate Records: on Database using SQL, or on file.txt using PHP?

From Dev

Search in a file for Specific sentences in a txt file in java

From Dev

Word search inside a file c

From Dev

Search string inside array javascript

From Dev

Add a file inside a folder to Github using JGit or EGit - directory1\myfile.txt

From Dev

How to search and replace all tags in HTML file using Vanilla JavaScript?

From Dev

Dynamically Call HTML File Using a Variable or JavaScript to give search results?

From Dev

Search for file end with .txt in subdirectories in linux

From Dev

python, search .txt file and inject character

From Dev

Flag controlled while loop to search txt file

From Dev

Search and extract text out of a txt file

From Dev

How to create search tab and open the .txt file?

From Dev

search in txt file and put the result in text box

From Dev

python, search .txt file and inject character

From Dev

Search and replace from txt file on many files?

From Dev

Search number from 'txt A' and replace into csv file

From Dev

Search txt file for varying keyword - then assign to variable

Related Related

  1. 1

    Search for a double word inside .txt file using batch file

  2. 2

    BufferedReader - Search for string inside .txt file

  3. 3

    reading a txt file line by line using JavaScript

  4. 4

    How to search txt file from python using while loop

  5. 5

    Using "-t" option inside a requirements.txt file

  6. 6

    How to search for JavaScript variables in a file, using Python?

  7. 7

    How to search for a string inside an array elements using javascript?

  8. 8

    Optimize string search in .txt file

  9. 9

    How to search a txt file for regex?

  10. 10

    Load text from local .txt file into html textarea using JavaScript

  11. 11

    Reading data from txt file using javascript, every 5 min

  12. 12

    Is it possible to write text in .txt file using angularjs or javascript?

  13. 13

    search for Duplicate Records: on Database using SQL, or on file.txt using PHP?

  14. 14

    Search in a file for Specific sentences in a txt file in java

  15. 15

    Word search inside a file c

  16. 16

    Search string inside array javascript

  17. 17

    Add a file inside a folder to Github using JGit or EGit - directory1\myfile.txt

  18. 18

    How to search and replace all tags in HTML file using Vanilla JavaScript?

  19. 19

    Dynamically Call HTML File Using a Variable or JavaScript to give search results?

  20. 20

    Search for file end with .txt in subdirectories in linux

  21. 21

    python, search .txt file and inject character

  22. 22

    Flag controlled while loop to search txt file

  23. 23

    Search and extract text out of a txt file

  24. 24

    How to create search tab and open the .txt file?

  25. 25

    search in txt file and put the result in text box

  26. 26

    python, search .txt file and inject character

  27. 27

    Search and replace from txt file on many files?

  28. 28

    Search number from 'txt A' and replace into csv file

  29. 29

    Search txt file for varying keyword - then assign to variable

HotTag

Archive