A
A
Anton Fedoryan2015-10-08 12:11:24
PHP
Anton Fedoryan, 2015-10-08 12:11:24

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

4 answer(s)
I
Ivanq, 2015-10-08
@AnnTHony

It is possible, through AJAX. If you don't know what it is, let's talk

D
Dmitry Kim, 2015-10-08
@kimono

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');
  });
});

E
Evgeny Petrov, 2015-10-08
@EvgenZZ

jQuery.ajaxSetup({cache:false});
jQuery.getJSON(link, function(data) {})

O
Online store without Php, 2016-04-09
@HEEG

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 question

Ask a Question

731 491 924 answers to any question