Doubt ajax to create a JS page

0

How do I create a javascript page that contains a button that, when I click, it accesses, via ajax, the contents of a txt file that is saved in the same folder as the page in question, and also displays its given inside a div with the id="data".

Thank you.

    
asked by anonymous 27.07.2017 / 20:55

1 answer

0

$.ajax({
			url: 'arquivo.txt',
			success: function(data){
				$('#app').append(data)
			}
		})	
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="app">

So, remembering that if it does not work, it does not have the file in the current directory

    
27.07.2017 / 21:02