A
A
Alex_872022-02-25 14:09:46
AJAX
Alex_87, 2022-02-25 14:09:46

How to send an ajax request, given that the site is on wordpress?

Please tell me, from the point of view of the Ajax request in wordpress, is this code written correctly? If yes, how can I make sure that the data came to the dae file?
Below is a diagram of what should happen after pressing the button. The action marked in red is already being executed by
6218b87151aff067747019.png

calculate.js:

jQuery( function( $ ){
   jQuery( 'button-range-submit' ).click(function(){
    const body = {
    }
    jQuery.ajax({
      url: 'https://maxcredit.proiectmd.com/dae/',
      type: 'POST',
      contentType: 'application/json',
      data: JSON.stringify({getoutSUM: outSUM, getoutVal: outVal, getarrDate: arrDate}),
      success: function( data ) {
        console.log( data );
      }
    });

   });
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Ivanov, 2022-03-03
@PlugIN

Yes, WP has its own rules for working with AJAX, now I'll throw off the link.

A
Artem Zolin, 2022-03-11
@artzolin

Check out the documentation for ajax requests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question