P
P
Pavel2019-03-15 10:21:08
JavaScript
Pavel, 2019-03-15 10:21:08

How to make and send json to the server?

on jquery I form such a string from the data that is in the input value

('2019-03-12', '14', '1', '9', '10', '2', '12'),
 ('2019-03-12', '11', '1', '9', '10', '4', '8'),
 ('2019-03-12', '13', '1', '20', '21', '2', '8'),
 ('2019-03-12', '9', '1', '9', '10', '3', '10'),
 ('2019-03-12', '10', '1', '9', '10', '3', '10'),
 ('2019-03-12', '12', '1', '20', '21', '1', '9')


this data is already valid, there is a huge form for 350+ inputs. The fact is that I now need to operate with this data on the server, and in the form of a string it’s already .. I must apparently do the json format and only then process it, the question is:
it will be more correct to transfer all the data and process it already on the server or validation can be carried out on the side client to filter out unnecessary data?
And the second question: I can form a string in the correct json syntax, but is this correct or do I need to do something like form.serialize()?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2019-03-15
@mrusklon

You don't seem to need JSON either. Send your data to the server in the body. And to the server that your string is parsed into an array that is JSON.
Validation should be carried out both there and there, since unreliable data may come from the client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question