L
L
LinuxGod2021-06-11 23:22:57
JavaScript
LinuxGod, 2021-06-11 23:22:57

Why does the jQuery request always get a different value?

Hello, I ran into this problem when writing a web client:
I access the server like this:

$.post('/data', {
          act: 'send'
        }, function (p) {
          console.log(p)
        })


The server processes the request, and if the input data (in my case it is act) is equal to "send", then the server sends an array consisting of objects to the client. But for some reason, every time I "spam" requests to the server, I get a different length of this array (some of the objects were simply lost!). Although, when testing directly on the server, everything works. Tell me what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Leleka, 2021-06-12
@LinuxGod

Try sending data via
$.ajax() instead of post. Specify
the data type in json format.
Just sending large post and get requests, the data has a size limit, so some of the data (post, get lines) may be cut off.
To test this theory, send a 10 character test message and see if your code works?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question