Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery post upload file


 $(document).ready(function() {
     $('#ProblemUpload').submit(function(e){
         e.preventDefault();
          $('#ProblemUpload').find('button').prop('disabled',true);
            var file_data = $('#fileData').prop('files')[0];   
            var form_data = new FormData();                  
            form_data.append('file', file_data);
            form_data.append('action', 'upload_sheet');
            $('#loaderWapper').slideDown();                         
            $.ajax({
                url: baseUrl+'apis/auth.php', // <-- point to server-side PHP script 
                dataType: 'text',  // <-- what to expect back from the PHP script, if anything
                cache: false,
                contentType: false,
                processData: false,
                data: form_data,                         
                type: 'post',
                success: function(php_script_response){
                    let response = JSON.parse(php_script_response);
                    if(response.status == 'success'){
                        alertify.alert('Data inserted',response.msg );
                        $('#ProblemUpload').trigger('reset');
                    }else{
                        alertify.error(response.msg)
                    }
                    $('#loaderWapper').slideUp();    
                    $('#ProblemUpload').find('button').prop('disabled',false);
                }
            });
     })
 })
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript array of all characters 
Javascript :: nestjs create controller with cmd 
Javascript :: TypeError: date.getHours is not a function 
Javascript :: event listener to elements with class 
Javascript :: js int to string 
Javascript :: check device type in javascript 
Javascript :: dd.mm.yyyy pattern regex 
Javascript :: react router dom v6 goback 
Javascript :: how to upgrade to react 18 
Javascript :: load json 
Javascript :: javascript set html value div 
Javascript :: how to clear pod cache in react native 
Javascript :: jquery slidetoggle 
Javascript :: selectpicker append option 
Javascript :: javascript get date of last monday 
Javascript :: the engine node is incompatible with this module 
Javascript :: noconflict jquery 
Javascript :: nodejs get current directory 
Javascript :: pdf darkmode 
Javascript :: js how to know the laster number of a number 
Javascript :: error: listen eaddrinuse: address already in use 0.0.0.0:5555 
Javascript :: javascript get if IE11 
Javascript :: nodefetch of ES modules is not supported. 
Javascript :: js wrap an element 
Javascript :: usehistory 
Javascript :: js time difference in minutes 
Javascript :: import paper material ui 
Javascript :: getelementbyid 
Javascript :: regex cnpj javascript 
Javascript :: return value from fetch javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =