更新代码在PHP中不适用于jquery Ajax?
我有4张独立的桌子——螺柱、国家硕士、学术硕士、国家硕士、城市硕士。我正在尝试更新,但它会打开模式并显示所有获取的值,然后当我更改值并单击“更新”时,模式会关闭,数据不会更新。你能说我做错了什么吗?先谢谢你。 我的更新按钮看起来像这样更新代码在PHP中不适用于jquery Ajax?,jquery,ajax,sql-update,Jquery,Ajax,Sql Update,我有4张独立的桌子——螺柱、国家硕士、学术硕士、国家硕士、城市硕士。我正在尝试更新,但它会打开模式并显示所有获取的值,然后当我更改值并单击“更新”时,模式会关闭,数据不会更新。你能说我做错了什么吗?先谢谢你。 我的更新按钮看起来像这样 <button type="submit" name="update" class="btn btn-info">Update</button> 和update.php页面 <?php include("connection.php
<button type="submit" name="update" class="btn btn-info">Update</button>
和update.php页面
<?php
include("connection.php");
$no=$_POST['stud_no'];
$name=trim($_POST['name']);
$mob=trim($_POST['mob_no']);
$dob=trim($_POST['dob']);
$add=trim($_POST['add']);
$photo=trim($_FILES['photo']['name']);
$gen=trim($_POST['gender']);
$cn=trim($_POST['country']);
$st=trim($_POST['state']);
$ct=trim($_POST['city']);
if(isset($_POST['stud_no'])){
$id= $_POST["stud_no"];
$qry="select * from stud s, country_master_academic c,master_state st, master_city ct where s.country=c.country_code and s.state=st.state_code and s.city=ct.city_code and stud_no='".$id."'";
$res = mysqli_query($conn,$qry);
$row=mysqli_fetch_array($res);
echo json_encode($row);
}
else
{
$qry="update stud set stud_name='$name',mobile='$mob',dob='$dob',address='$add',gender='$gen',country='$cn',state='$st',city='$ct' where stud_no='$no'";
$data=mysqli_query($conn,$qry);
if($data)
{
echo '<script language="javascript">';
echo 'alert("Updated Successfully")';
echo '</script>';
}
else {
echo '<script language="javascript">';
echo 'alert("Cannot update record")';
echo '</script>';
}
if(!empty($_FILES['photo']['name'])){
$qry1= "update stud set photo='$photo' where stud_no='$no'";
$data1=mysqli_query($conn,$qry1);
if($data1){
$target_dir="images/";
$target_file=$target_dir.basename($_FILES["photo"]["name"]);
$imageFileType=pathinfo($target_file,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["photo"]["tmp_name"],$target_file)){
echo '<script language="javascript">';
echo 'alert("Image upload successfully")';
echo '</script>';
} else {
echo '<script language="javascript">';
echo 'alert("Cannot Upload")';
echo '</script>';
}
}
}
}
html:
<form id="FormSubmit" method="post">
@Yogendrasinh我在这里问了一个新问题that@BhoomiPatel看到这位女士了吗
<form id="FormSubmit" method="post">
$(document).ready(function(){
$( "#FormSubmit" ).submit(function( event ) {
event.preventDefault();
$.ajax ({
url: "update.php",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(response) {
console.log(response);
}
});
});
});