Monty Monty - 7 months ago 33
jQuery Question

Sending ID data with jQuery AJAX

I need to fetch my id and Edit the tables value..but i am not able to fetch id from database and actually i am trying to send it by this way....

$(document).on('submit', '#form_company.edit', function(e){
// Validate form
if (form_company.valid() == true){
// Send company information to database
var id = $('#form_company').attr('data-id');
var form_data = $('#form_company').serialize();
var request =

url: 'data.php?job=edit_company&id=' + id,
cache: false,
data: form_data,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
type: 'get'


but it is getting passed by URL ..i want to send it by "data:" to do it..


You can post both data in POST parameter like below:-

  url:          'data.php',
  type:          'POST',
  cache:        false,
  data:         {'form_data':form_data,'job':'get_company','id': id} ,
  dataType:     'json',
  contentType:  'application/json; charset=utf-8',


And now in php (data.php):-


Note:- based on this printed data you can do your stuff accordingly. Thanks