i have been working on some project and getting some experience on php and ajax, jquery. So i have checked 20+ question on stackoverflow but couldnt find the solution even if its already answered the same question.
I have tryed 10 diffrent solution but i guess im skipping something.
I have simple select box and im using ajax to send mysql but only select box doesnt work for some reason.
HTML Code:
<section class="resume-section p-3 p-lg-5 d-flex flex-column" id="rezervasyon">
<div class="my-auto">
<h2 class="mb-5">Online Rezervasyon</h2>
<form id="loginForm" method="" action="" novalidate="novalidate">
<div class="form-group row">
<label for="rez_ad" class="col-sm-2 col-form-label">İsim Soyisim</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="rez_ad" id="rez_ad" placeholder="İsim Soyisim">
</div>
</div>
<div class="form-group row">
<label for="rez_saat" class="col-sm-2 col-form-label">Rezervasyon Saati</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="rez_saat" id="rez_saat" placeholder="Rezervasyon saati">
</div>
</div>
<div class="form-group row">
<label for="rez_gsm" class="col-sm-2 col-form-label">Cep Numaranız</label>
<div class="col-sm-10">
<input type="number" class="form-control" name="rez_gsm" id="rez_gsm" placeholder="İletişim numaranız.">
</div>
</div>
<div class="form-group row">
<label for="rez_tarih" class="col-sm-2 col-form-label">Tarih</label>
<div class="col-sm-10">
<input type="date" class="form-control" name="rez_tarih" id="rez_tarih" placeholder="Tarih belirtiniz.">
</div>
</div>
<div class="form-group row">
<label for="rez_email" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="rez_email" id="rez_email" placeholder="Email">
</div>
</div>
<div class="form-group row">
<label for="rez_tip" class="col-sm-2 col-form-label" name="rez_tip" id="rez_tip">Rezervasyon Tipi</label>
<div class="col-sm-10">
<select id="rez_tip" class="custom-select">
<option value="" selected>Rezervasyon Tipi Seçiniz</option>
<option value="1">Cuma Fix Menü</option>
<option value="2">Cumartesi Fix Menü</option>
<option value="3">Haftaiçi ALKOLSÜZ</option>
<option value="4">Haftaiçi ALKOLLÜ</option>
<option value="5">Kutlama / Doğum Günü</option>
<option value="6">Diğer</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="rez_sayi" class="col-sm-2 col-form-label" id="rez_sayi" name="rez_sayi">Kişi Sayısı</label>
<div class="col-sm-10">
<select id="rez_sayi" class="custom-select">
<option value="" selected>Kişi Sayısı Belirtiniz</option>
<option value="1">2 Kişilik Rezervasyon</option>
<option value="2">4 Kişilik Rezervasyon</option>
<option value="3">4+ Kişilik Rezervasyon</option>
<option value="4">6+ Kişilik Rezervasyon</option>
<option value="5">8+ Kişilik Rezervasyon</option>
<option value="6">20+ Kişilik Rezervasyon</option>
</select>
</div>
</div>
<textarea name="rez_aciklama" id="rez_aciklama" class="form-control" rows="6" cols="21" required="required"
placeholder="Ek açıklama girebilirsiniz."></textarea>
<form class="was-validated">
<!-- Button trigger modal -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title text-center" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="divider"></div>
<div class="right-side">
<button type="button" class="btn btn-danger btn-link">Delete</button>
</div>
</div>
</div>
</div>
</div>
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="customControlValidation1" required>
<label class="custom-control-label" for="customControlValidation1">Rezervasyon Şartlarını Kabul Ediyorum!</label>
<div class="invalid-feedback">Rezervasyon şartlarını okuyunuz!</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="button" class="btn btn-success" name="insert-data" id="insert-data" onclick="insertData()">Rezervasyonu Tamamla</button>
</div>
</div>
<br>
<p id="message"></p>
</form>
Here is my php file ;
<?php
include('db.php');
$rez_ad=$_POST['rez_ad'];
$rez_saat=$_POST['rez_saat'];
$rez_gsm=$_POST['rez_gsm'];
$rez_tarih=$_POST['rez_tarih'];
$rez_tip=$_POST['rez_tip'];
$rez_sayi=$_POST['rez_sayi'];
$rez_aciklama=$_POST['rez_aciklama'];
$stmt = $DBcon->prepare("INSERT INTO student(rez_ad,rez_saat,rez_gsm,rez_tarih,rez_tip,rez_sayi,rez_aciklama) VALUES(:rez_ad, :rez_saat,:rez_gsm,:rez_tarih,:rez_tip,:rez_sayi,:rez_aciklama)");
$stmt->bindparam(':rez_ad', $rez_ad);
$stmt->bindparam(':rez_saat', $rez_saat);
$stmt->bindparam(':rez_gsm', $rez_gsm);
$stmt->bindparam(':rez_tarih', $rez_tarih);
$stmt->bindparam(':rez_tip', $rez_tip);
$stmt->bindparam(':rez_sayi', $rez_sayi);
$stmt->bindparam(':rez_aciklama', $rez_aciklama);
if($stmt->execute())
{
$res="Data Inserted Successfully:";
echo json_encode($res);
}
else {
$error="Not Inserted,Some Probelm occur.";
echo json_encode($error);
}
?>
Here is my jquery code;
function insertData() {
var rez_ad=$("#rez_ad").val();
var rez_saat=$("#rez_saat").val();
var rez_gsm=$("#rez_gsm").val();
var rez_tarih=$("#rez_tarih").val();
var rez_tip=$("#rez_tip").val();
var rez_sayi=$("#rez_sayi").val();
var rez_aciklama=$("#rez_aciklama").val();
// AJAX code to send data to php file.
$.ajax({
type: "POST",
url: "rez/insert-data.php",
data: {rez_ad:rez_ad,rez_saat:rez_saat,rez_gsm:rez_gsm,rez_tarih:rez_tarih,rez_tip:rez_tip,rez_sayi:rez_sayi,rez_aciklama:rez_aciklama},
dataType: "JSON",
success: function(data) {
$("#message").html(data);
$("p").addClass("alert alert-success");
},
error: function(err) {
alert(err);
}
});
}
Thanks for help !
You should then pass the rez_tip option in ajax call also.
<script type="text/javascript">
function insertData() {
//var rez_tip=$("#rez_tip option:selected").text();
//var rez_sayi=$("#rez_sayi option:selected").text();
var rez_tip=$("select#rez_tip").val();
var rez_sayi=$("select#rez_sayi").val();
// AJAX code to send data to php file.
$.ajax({
type: "POST",
url: "rez/insert-data.php",
data: {rez_sayi:rez_sayi,rez_tip:rez_tip},
dataType: "JSON",
success: function(data) {
$("#message").html(data);
$("p").addClass("alert alert-success");
},
error: function(err) {
alert(err);
}
});
}
</script>
Related
$("#create-center-form").submit(function(e){
e.preventDefault();
let parent;
let _token = $("input[name=_token]").val();
let name=$("#name_create_medical_center").val();
let email=$("#email_create_medical_center").val();
let phone=$("#phone_number_create_medical_center").val();
let country_id=$("#country_selector_create").val();
let state_id=$("#state_selector_create").val();
let city_id=$("#city_selector_create").val();
let country_name=$("#country_selector_create option:selected").text();
let state_name=$("#state_selector_create option:selected").text();
let city_name=$("#city_selector_create option:selected").text();
if($("#center_selector").is(":visible")){
parent=$("#center_selector option:selected").val();
}
else
parent="";
console.log(name);
console.log(email);
console.log(phone);
$("#first_button_create").prop('disabled', true);
$.ajax({
url:"{{route('add-medical-center')}}",
type:"POST",
data:{
_token:_token,
type:type,
name:name,
email:email,
phone:phone,
country_id:country_id,
state_id:state_id,
city_id:city_id,
country_name:country_name,
state_name:state_name,
city_name:city_name,
parent_id:parent,
},
success:function(response){
$("#tbody1").append(
'<tr>'+
'<td>'+response.id+'</td>'+
'<td>'+response.name+' </td>'+
'<td>'+response.address+' </td>'+
'<td>'+response.email+' </td>'+
'<td>'+response.phone+'</td>'+
'<td>'+
'<img src="https://img.icons8.com/material-sharp/24/26e07f/edit--v1.png" />'+
'<img src="https://img.icons8.com/ios-filled/50/fa314a/full-trash--v2.png" width="25"/>'+
'</td>'+
'</tr>'
);
alert("your response has been added!");
$("#create_modal").modal('hide');
$("#name_create_medical_center").val('');
$("#email_create_medical_center").val('');
$("#phone_number_create_medical_center").val('');
$('#country_selector_create').find('option').remove().end().append("<option value='select'> Select Country</option>");
$('#state_selector_create').find('option').remove().end().append("<option value='select'> Select State</option>");
$('#city_selector_create').find('option').remove().end().append("<option value='select'> Select City</option>");
$("#first_button_create").prop('disabled', false);
},
error:function(respomse){
alert("please check the input data and try again");
$("#first_button_create").prop('disabled', false);
},
});
});
Hello I'm using Laravel with Ajax and sending a form to add a record to the database but when submitting this form on the first time it works good but on the second, third, fourth … nth time it resends all of the old form submits.
,for example
submitting for the first time: works great it only sends the first time data
submitting for the second time: it sends the second time data and first time data
submitting for the third time: it sends the third, second and the first time data
so, on the second time instead of only adding one record to my data base I'm adding two records the new and old one and in the third time I'm adding three recode the new and old ones and goes on....
the html/bootstrap modal that contains the form:
<div id="create_modal" class="modal fade" role="dialog" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Add New User</h3>
</div>
<div class="modal-body">
<form id="create-center-form" class="ajax-form form-horizontal" enctype="multipart/form-data">
#csrf
<input type="hidden" id="hidden_create" value="">
<!-- First Name -->
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">Name</label>
<div class="col-md-6">
<input id="name_create_medical_center" type="text" class="form-control" name="first_name" value="" required autocomplete="first_name" autofocus>
</div>
</div>
<!-- Main Center -->
<div class="form-group row">
<label for="main_center" class="col-md-4 col-form-label text-md-right">Has a Main Center</label>
<div class="col-md-6">
<input type="checkbox" class="onoffswitch-checkbox" id="has_main_center" checked>
</div>
</div>
<!-- Select Main Center -->
<div class="form-group row" id="center_selector">
<label for="main_center" class="col-md-4 col-form-label text-md-right">Select Center:</label>
<div class="col-md-6">
<select class="form-select" aria-label="Default select example" id="medical_center_selector" >
<option selected>Select The Main Center</option>
</select>
</div>
</div>
<!-- Email Address -->
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">Email</label>
<div class="col-md-6">
<input id="email_create_medical_center" type="email" class="form-control" name="Emial" value="" required autocomplete="email">
</div>
</div>
<!-- Phone Number -->
<div class="form-group row">
<label for="phone_number" class="col-md-4 col-form-label text-md-right">Phone Number</label>
<div class="col-md-6">
<input id="phone_number_create_medical_center" type="text" class="form-control" name="phone_number" value="" required autocomplete="Password">
</div>
</div>
<!-- Country, State and City -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<select class="form-select" aria-label="Default select example" id="country_selector_create" >
<option selected>Select Country</option>
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<select class="form-select" id="state_selector_create" onchange="">
<option selected>Select State</option>
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<select class="form-select" aria-label="Default select example" id="city_selector_create">
<option selected>Select City</option>
</select>
</div>
</div>
</div>
<div class="form-group row">
<input type="hidden" name="action" id="user-form-action" value="create" />
<input type="hidden" name="hidden_id" id="user-hidden-id" />
<button type="submit" name="create_update_user" id="user-form-action-button" value="create" class="btn btn-warning">Submit</button>
</div>
</form>
</div>
</div>
</div>
You are working with modals (Bootstrap). All good. The thing is, they are cached in the browser. You probably close the modal and open a new one. This could be the reason you are sending twice or more the same data.
Instead of
$("#create_modal").modal('hide');
use
$("#create_modal").modal('dispose');
to destroy it's instance as explained at https://getbootstrap.com/docs/4.6/components/modal/#modaldispose
A user's request to open a new modal will simply create a new instance of the modal. I hope this solves your issue. It's worth a try.
I am sending form parameters using serialize() method but the problem is parameters sent are visible in address bar. Even I am using POST method for AJAX request.
Here is the HTML Code for the form I am try to submit.
<form id="addform" method="post">
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputReminder">Reminder Type</label>
<select id="inputReminder" class="form-control" name="inputReminder">
<option value="I">Reminder I</option>
<option value="II">Reminder II</option>
<option value="III">Reminder III</option>
<option value="General">General</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputLetterref">Reminder Reference No.</label>
<input type="text" class="form-control" id="inputLetterref" name="inputLetterref" placeholder="Reminder Reference No." required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputLetterdate">Reminder Date</label>
<input type="text" readonly="readonly" class="form-control sel-date" id="inputLetterdate" name="inputLetterdate" placeholder="Reminder Date" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary">Add Reminder </button>
</div>
</div>
</form>
jQuery AJAX request:
$("#addform").submit(function(event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: 'submitdetails.php',
data: $(this).serialize()
}).done(function(data) {
$('#result').html(data);
}).error(function(data) {
$('#result').html(data);
});
});
You can try:
$("#addform").submit(function(event){
event.preventDefault();
$.ajax({
type: 'POST',
url : 'submitdetails.php',
data: $(this).serialize(),
done: function(data){
console.log(data)
$('#result').html(data);
},
fail: function(data){
$('#result').html(data);
}
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="addform" method="post">
<div class="form-row" id="reminderresult">
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputReminder">Reminder Type</label>
<select id="inputReminder" class="form-control" name="inputReminder">
<option value="I">Reminder I</option>
<option value="II">Reminder II</option>
<option value="III">Reminder III</option>
<option value="General">General</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputLetterref">Reminder Reference No.</label>
<input type="text" class="form-control" id="inputLetterref" name="inputLetterref" placeholder="Reminder Reference No." required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputLetterdate">Reminder Date</label>
<input type="text" readonly="readonly" class="form-control sel-date" id="inputLetterdate" name="inputLetterdate" placeholder="Reminder Date" required>
</div>
</div>
<button type="submit" class="btn btn-primary">Add Reminder </button>
</form>
I'm writing a dynamic form that appends available text-fields depending on value that was selected by the user. How do I make it work? For context, it's an edit button, so the text-field will be pre-filled with STRING from the database.
The functions of getting the data from the database works, and the modal also shows, but the problem is just that the select-form doesn't work.
I tried calling "#btn-edit-account" but it doesn't work.
Code for the modal edit-account
<div class="modal fade" id="edit-account-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Edit Account Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-add" role="tabpanel" aria-labelledby="nav-home-tab">
<form id="form-edit-account">
<input type="hidden" name="_token" value="{{csrf_token()}}">
<div class="container my-2">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Role</label>
<select type="select" id="select-role" class="form-control edit_role select-role" name="role_id" required>
</select>
</div>
<div class="form-group student-number-container hidden">
<label>Student Number</label>
<input type="text" class="form-control" id="edit_student_number" name="student_number" required>
</div>
<div class="organization-container hidden">
</div>
<div class="form-row">
<div class="col-md-6">
<label>First name</label>
<input type="text" class="form-control" id="edit_first_name" name="first_name" required>
</div>
<input type="hidden" id="token" name="_token" value="{{csrf_token()}}">
<div class="col-md-6">
<label>Last Name</label>
<input type="text" class="form-control" id="edit_last_name" name="last_name" required>
</div>
</div>
<div class="form-group">
<label>Email</label>
<input type="email" class="form-control" id="edit_email" name="email">
</div>
<div class="form-row">
<label class="control-label">New Password <span class="required">*</span></label>
<input type="password" id="new_password" name="new_password" minlength="6" class="form-control password" required>
</div>
<div class="form-row">
<label class="control-label">Confirm New Password <span class="required">*</span></label>
<input type="password" id="confirm_password" name="confirm_password" minlength="6" class="form-control password" required>
</div>
<div class="form-group text-right mt-4">
<button type="button" class="btn btn-dark" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success btn-confirm-edit-account">Update</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Javascript for btn-edit-account
$(document).on('click', '.btn-edit-account', function() {
$('#edit-account-modal').modal('show');
var id = $(this).attr('data-id');
$.ajax({
url: "users/get-specific-user-info",
type: "POST",
data: {
id: id,
_token: "{{csrf_token()}}"
},
success: function(data) {
// $('#edit_role').val(data.role_id);
$('#edit_first_name').val(data.first_name);
$('#edit_last_name').val(data.last_name);
$('#edit_email').val(data.email);
console.log(data);
}
});
});
});
Javascript for select-role
$(document).on('change', '#select-role', function() {
var val = $(this).val();
if(val != 3){
$('.student-number-container').show();
}
else {
$('.student-number-container').hide();
}
if(val != 1){
$('.organization-container').html("");
}
else {
appendOrganization();
$('.organization-container').show();
}
});
function for appendOrganization
function appendOrganization() {
var html = "";
html += '<div class="form-group"> <label>Organization Name</label> <input type="text" class="form-control" name="organization_name" required> </div>';
html += '<div class="form-group"> <label>Organization Type</label> <select type="select" id="select-org-type" class="form-control" name="organization_type" required>'+
'<option value="" selected disabled>Select Organization Type</option>'+
'<option value="TYPE A">TYPE A</option>'+
'<option value="TYPE B">TYPE B</option>'+
'</select></div>';
html += '<div class="form-group"> <label>College</label> <select type="select" id="select-org-type" class="form-control" name="organization_college" required> <option value="" selected disabled>Select Organization Type</option> <option value="COLLEGE ONE">COLLEGE ONE</option> <option value="COLLEGE TWO">COLLEGE TWO</option> </select> </div>';
$('.organization-container').html(html);
}
The select in the modal should show the available choices in the given select, then will dynamically change the form depending on the selected choice.
attribute required not working when I submitted data with Ajax if I change on click with submitting data not insert, just success insert with on click, this my code. this is in form wizard #jquery #Codeigniter
<form action="#">
<div class="form-group row">
<div class="col-sm-7">
<h3 class="wizard-title">Data Surat</h3>
</div>
</div>
<div class="form-group row">
<label class="col-12 col-sm-3 col-form-label text-left text-sm-right">Nomor</label>
<div class="col-12 col-sm-8 col-lg-6">
<input class="form-control" type="text" required placeholder="Nomor Surat" id="nomor" name="nomor">
</div>
</div>
<div class="form-group row">
<label class="col-12 col-sm-3 col-form-label text-left text-sm-right">Tanggal</label>
<div class="col-12 col-sm-8 col-lg-6">
<input class="form-control" type="date" required name="tanggal" id="tanggal" placeholder="Tanggal">
</div>
</div>
<div class="form-group row">
<label class="col-12 col-sm-3 col-form-label text-left text-sm-right">Tujuan</label>
<div class="col-12 col-sm-8 col-lg-6">
<Textarea class="form-control" required name="tujuan" id="tujuan" ></Textarea>
</div>
</div>
<div class="form-group row">
<div class="offset-sm-2 col-sm-10">
<!-- <input type="button" onclick="myFunction()" class="btn btn-secondary btn-space" value="Reset"> -->
<button class="btn btn-primary btn-space wizard-next" id="btn_save" type="submit" data-wizard="#wizard1">Selanjutnya</button>
</div>
</div>
</form>
this is my script ajax
<script type="text/javascript">
$(document).ready(function() {
//Save product
$('#btn_save').on('click', function(e) {
e.preventDefault();
if(! $form.valid()) return false;
var $form = $(this);
var nomor = $('#nomor').val();
var tanggal = $('#tanggal').val();
var tujuan = $('#tujuan').val();
$.ajax({
type: "POST",
url: "<?php echo site_url('users/bendahara/sp/save')?>",
dataType: "JSON",
data: {
nomor: nomor,
tanggal: tanggal,
tujuan: tujuan
},
success: function(data) {
$('[name="nomor"]').val("");
$('[name="tanggal"]').val("");
$('[name="tujuan"]').val("");
// show_product();
}
});
return false;
});
});
</script>
Maybe you know
required is working
In the database I have a table called articles. On one page of my website there is a list of titles of all articles - and each title is actually a link to edit the article. It looks like this:
<a onclick="launch_edit_modal(<?php echo $article->getId(); ?>)" data-toggle="modal" data-target="#edit_modal" href="#">Edit</a>
When you click on the link - function launch_edit_modal(id_of_article) is triggered:
<script type="text/javascript">
$('#edit_modal').modal({
show: false
});
function launch_edit_modal(id) {
$.ajax({
type: "POST",
url: "return_article_data.php",
data: {
id:id
},
dataType: "json",
success: function(data) {
$("#category").val(data.category_id);
$("#title").val(data.title);
$("#content").val(data.content);
$('#edit_modal').show();
}
});
}
</script>
This script is at the bottom.
So, using AJAX I find the other data (category, title, content) about that article and then I update the form which is modal's content:
<div class="modal fade" id="edit_modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
<h3 class="modal-title">Edit article</h3>
</div>
<div class="modal-body">
<div class="row">
<form id="edit_forma" class="form-horizontal" method="post" action="edit_article.php">
<fieldset>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="selectbasic">Category:</label>
<div class="col-md-4">
<select id="category" name="category" class="form-control">
<?php foreach($categories as $c): ?>
<option value="<?php echo $c->getId(); ?>"><?php echo $c->getName(); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="title">Title:</label>
<div class="col-md-4">
<input id="title" name="title" placeholder="" class="form-control input-md" type="text">
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-4 control-label" for="content">Content:</label>
<div class="col-md-4">
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button type="submit" id="submit" name="submit" class="btn btn-success">Izmeni</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default">
Close
</button>
</div>
</div>
</div>
</div>
All of this works - but there is a problem - when I click on edit link - Modal is shown, and then after 2 or 3 seconds the form is filled (updated) with data.
Is there a way to fix this - to show Modal after the form is filled (updated)?
Thanks in advance.
As Ghazanfar Mir wrote in the comments below my question, I need just to set:
async: false
for ajax call, and the problem is solved.
Thank you Ghazanfar Mir.