7

Actually i am using following script to post my form

var formData = new FormData($("form#driver_information")[0]);
$.ajax({
    type: "POST",
    url: "/",
    data: formData, 
    success: function(data) {
    $("#page_message_box").html(data);
    },
    cache: false,
    contentType: false,
    processData: false
});

I need to pass some more variables along with form data

eg:

var formData = new FormData($("form#driver_information")[0]);
 $.ajax({
  type: "POST",
  url: "/",
  data: formData + "&con=delete",  
  success: function(data) {
  $("#page_message_box").html(data);
 },
   cache: false,
   contentType: false,
   processData: false
});

But it's not working.( data: formData + "&con=delete", ). Please help to solve this problem.

1
  • formData.append('varname', varname); Commented Nov 18, 2015 at 10:02

2 Answers 2

7

Try this:

formData.append('con', 'delete');

before the $.ajax call.

Then within that call you just need:

data: formData,
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much @rlarcombe
1

You can append data to FormData like this:

formData.append('con', 'delete');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.