$(document).on('click','.locations',function(e){ e.preventDefault(); if(data.length > 1){ $.post('/home/locations',{'locations': JSON.stringify(data)},function(result){ res = JSON.parse(result); if(res['resp'] == 1){ $('.map_id').val(res['map_id']); } });} $('form').submit();}); 

The request itself. Tried to do prevent (disable submit) but the data comes after the submission and bd does not get a value with .map_id

  • on the form there is action = "javascript: void (null);" ? - larrymacbarry
  • Yes, the form has action = "javascript: void (null);" - Subhonkulov
  • so you do not want to make in the success-processor Ajax request that? PS: why do you need stringify ? - teran
  • I want to submit, but only after the result obtained from the Ajax request is entered into .map_Id - Subhonkulov

1 answer 1

Move submit to colbeck

 $(document).on('click','.locations',function(e){ e.preventDefault(); if(data.length > 1){ $.post('/home/locations',{'locations': JSON.stringify(data)},function(result){ res = JSON.parse(result); if(res['resp'] == 1){ $('.map_id').val(res['map_id']); } $('form').submit();}) });}