Answer the question
In order to leave comments, you need to log in
Is it possible to upload data to the site using JS without PHP?
There is a button on the page. When clicked, an additional panel is shown and here I would like to load the text that lies in the file on the server.
Is it possible to somehow read a text file (on the server) using JS and display its contents?
Or what is the best way to do this?
Answer the question
In order to leave comments, you need to log in
Basically like this:
<div id="my-text"></div>
<button type="button" id="my-button">My button</button>
$(function(){
$('#my-button').on('click', function(){
$('#my-text').load('http://my-server.dot/my-text-file.txt');
});
});
jQuery.ajaxSetup({cache:false});
jQuery.getJSON(link, function(data) {})
You can do it the old fashioned way through JSONP, that is, you run a js script with parameters on another site that runs the script on yours. You can get a list of cities and calculate the delivery. Here is an example of such a js code novye-podarki.ru/heeg.html#%24%3A%2Fboot%2Fmodul_d... to test it, place an order and choose delivery to another city. But if possible, it is better to use CORS https://learn.javascript.ru/xhr-crossdomain
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question