I have problem with this code:
function sendData(nr) {
var data = $("#myform"+ nr).serialize();
// debug regeltje
console.log(data);
jQuery.ajax({
url: "inc/update.php",
data: data,
type: "POST",
cache: false,
success:function(data)
{
if(data=='success') {
$("#container").load(window.location + " #container");
// alert(data);
} else {
$("#container").load(window.location + " #container");
}
}
});
}
the first time I call this function it is working fine. But the second time it isn't. Debug Console gives no result.
This is my update.php
file
<?php
session_start();
include("config.php");
include("function.php");
include("class.User.php");
$Func = new Func($db);
if(isset($_SESSION['userData'])) {
$User = new GUser($db,$Func, $_SESSION['userData']['oauth_uid']);
}
//echo var_dump($_POST);
if(isset($_POST['color'])) {
$query = $db->query('UPDATE user_fleet SET train_row_color = "'.$db->real_escape_string($_POST['color']).'" WHERE id = "'.$db->real_escape_string($_POST['id']).'"');
}
After I refresh the whole page then it's working fine for only one time again.
Why is this happening?
I call the sendData
from fleet.php
<tr style="background-color: #'.$res['train_row_color'].';">
<form method="post" action="" id="myform'.++$i.'">
<td>
<select class="test" name="color" onchange="sendData('.$i.');">
<option value="0"></option>
<option value="ff0000" style="background-color: #ff0000"></option>
<option value="3000ff" style="background-color: #3000ff"></option>
<option value="36ff00" style="background-color: #36ff00"></option>
<option value="e400ff" style="background-color: #e400ff"></option>
<option value="fff000" style="background-color: #fff000"></option>
</select>
</td>
This is inside a while
loop.
True Google Inspect and Network i see this
As you can see the second screen is not showing the form.