0
0
0906ddd2021-09-09 13:58:08
JavaScript
0906ddd, 2021-09-09 13:58:08

How to correctly set the action?

if i don't do it like this

$.ajax({
                url: myajax.url,
                type: 'POST', 
                cache: false,
                contentType: false,
                processData: false,
                data: data, 
                data: {
                    action: 'request',
                    phone: phone, 
                    email: email,
                    surname: surname,
                    name: name,
                    days: days,
                    money: money,
                },
              
             }).done(function(data){

 

            });
         }


but like this
if( typeof files == 'undefined' ) return;

      var data = new FormData();

      $.each( files, function( key, value ){
        data.append( key, value );
      });
    $.ajax({
                url: myajax.url,
                type: 'POST', 
                cache: false,
                contentType: false,
                processData: false,
                data: data, 
              
             }).done(function(data){

            });
         }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-09-09
@0906ddd

data.append('action', 'request');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question