Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Ajax Form All Data Send

 $('#submit').on('click', function() {
             $.ajax({
                 url: "controller/php/add_project.php",
                 type: "POST",
                 data:  new FormData(document.getElementById("add_project_form")),
                 contentType: false,
                 processData:false,
                 cache: false,
                 success: function(dataResult){
                        console.log(dataResult);
                        var dataResult = JSON.parse(dataResult);
                        
                 },
                 error:function(dataResult){
                     console.log(dataResult);
                     alert('error / Add Project Again');
                 }
             });
         });
Comment

ajax call with form data

$.ajax({
    url: "jobs/php/job_single.php?type=500",
    type: "POST",
    data:  new FormData(document.getElementById("form")),
    contentType: false,
    processData:false,
    cache: false,
    success: function(dataResult){
      console.log(dataResult);
      if(dataResult == 999){
        alert("Incomplete Information Provided");
      }
      else{
        if(dataResult == 1){
        	alert("Job Application successful");
        	location.reload();
        }
        else if(dataResult == 0){
        	alert("Error applying for job, Please try again");
        }

      }
    }
}); 
Comment

ajax get form data

var form = // Select your form here;
var fmData = new FormData();
form.append('name',fmData);
$.ajax({
  url:'URL',
  type:'POST',
  data:fmData,
  success:function(){},
  error:(er){}
})
Comment

.ajax how to get data from form

$.ajax({
    ...
    data: $("#registerSubmit").serialize(),
    ...
})
Comment

ajax submit form data

<form id="contactForm1" action="/your_url" method="post">
    <!-- Form input fields here (do not forget your name attributes). -->
</form>

<script type="text/javascript">
    var frm = $('#contactForm1');

    frm.submit(function (e) {

        e.preventDefault();

        $.ajax({
            type: frm.attr('method'),
            url: frm.attr('action'),
            data: frm.serialize(),
            success: function (data) {
                console.log('Submission was successful.');
                console.log(data);
            },
            error: function (data) {
                console.log('An error occurred.');
                console.log(data);
            },
        });
    });
</script>
Comment

Send Form Data Using Ky AJAX

async function(){
	const data = document.getElementById("myForm");
	
const fd =	new FormData(data);
let data = Object.fromEntries(fd);
 
const json = await ky.post('/test', {json: data}).json();

	console.log(json.x);
    
    
  ....
  <form id="myForm">
  <input name="value1" />
  </form>
Comment

PREVIOUS NEXT
Code Example
Javascript :: use history react router dom 
Javascript :: logbox ignore warnings 
Javascript :: daterangepicker change 
Javascript :: ejs / javascript check if array/object exists and is not empty 
Javascript :: socket io https 
Javascript :: react navigation transparent header 
Javascript :: how to get file extension in javascript last index 
Javascript :: javascript set file input value to null 
Javascript :: react localstorage 
Javascript :: Javascript remove array item by value 
Javascript :: trigger key jquery 
Javascript :: Cannot download "https://github.com/sass/node-sass 
Javascript :: negative reciprocal javascript 
Javascript :: console message inspector javascript 
Javascript :: javascript get a random number with 6 digits 
Javascript :: react native navigation back 
Javascript :: allow empty joi validation 
Javascript :: expo android package name 
Javascript :: number to money javascript 
Javascript :: onclick focus out jquery 
Javascript :: how to close modal using esc key in nuxt js 
Javascript :: render image url in react native 
Javascript :: angular find value in json array 
Javascript :: change value rateit.js using jquery 
Javascript :: how to check if iframe is loaded 
Javascript :: set timer jquery 
Javascript :: cannot find module loader 936 
Javascript :: javascript add class to all child elements 
Javascript :: how to find unique elements in array in javascript 
Javascript :: javascript string except last character 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =