D
D
deadshumz2021-11-19 14:27:53
AJAX
deadshumz, 2021-11-19 14:27:53

How to send data with AJAX string?

how to pass strings to body using fetch?
i need to send userName string and password string by POST method and get
json format response and read its first parameter. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2021-11-19
@Stalker_RED

https://developer.mozilla.org/en-US/docs/Web/API/F...

A
Aricus, 2021-11-19
@Aricus

As you said yourself, JSON.
In jquery:

$.ajax({
      type: "POST",
      url: "ajax/get_data_analogue.php",
      data: {analogue:thisData}
    }).done(function(result) {
      let resultData = $.parseJSON(result);
    })

In PHP page for AJAX: In jquery:
<?=json_encode($arr)?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question