اذهب إلى المحتوى
  • 1

parsererror SyntaxError: Unexpected token [Tabledit]

السؤال

نشر

سلام عليكم و رحمة الله و بركاته

استخدم مكتبة tableedit للتعديل الفوري على الجدول

الكود كالتالي

<?php
session_start();

if ($_SESSION['permission'] != 1)
header("location: login");

require("../includes/db.php");

//$getDATA = $conn->query("SELECT langName, langVar, translation FROM lang ");
$getDATA = $conn->query("SELECT * FROM lang ");

?>

<!doctype html>

<html lang="ar">

<head>

<?php include("../includes/head.php"); ?>
<title>إعدادات الترجمة</title>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="https://markcell.github.io/jquery-tabledit/assets/js/tabledit.min.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://markcell.github.io/jquery-tabledit/assets/js/tabledit.min.js"></script>

</head>

<body>

<?php include(ROOT ."/includes/loader.php"); ?>

<div class="app-container app-theme-white body-tabs-shadow fixed-sidebar fixed-header">

<?php include(ROOT ."/includes/app-header.php");


?>

<?php //include("includes/ui-theme-settings.php"); ?>

<div class="app-main">

<?php include(ROOT ."/includes/sidebar.php"); ?>

<div class="app-main__outer">

<div class="app-main__inner">

<div class="app-page-title">

    <div class="page-title-wrapper">

        <div class="page-title-heading">

            <div class="page-title-icon"> <i class="pe-7s-network icon-gradient bg-mean-fruit"> </i>

            </div>

            <div>

                إعدادات الترجمة

                <div class="page-title-subheading">إعدادات الترجمة </div>

            </div>

        </div>

    </div>

</div>

<div class="row">

<div class="col-12">
<div class="table-responsive">

<table id="editable_table" class="table table-bordered table-striped">
<thead>
<tr>
<th>ID</th>
<th>langName</th>
<th>langVar</th>
<th>translation</th>

</tr>
</thead>
<tbody>
<?php
foreach($getDATA AS $row)
{
echo '
<tr>
<td>'.$row["id"].'</td>
<td>'.$row["langName"].'</td>
<td>'.$row["langVar"].'</td>
<td>'.$row["translation"].'</td>
</tr>
';
}
?>
</tbody>
</table>
</div></div></div></div></div></div>


<?php include(ROOT ."/includes/footer.php"); ?>

</div>

</div>

</div>

<?php include(ROOT ."/includes/js.php"); ?>
</body>

</html>

<script>
$(document).ready(function(){
$('#editable_table').Tabledit({
url:'lang/action.php',
columns:{
identifier:[0, "id"],
editable:[[3, 'translation']]
},
restoreButton:false,
deleteButton:false,
editButton:true,
onSuccess: function(data, textStatus, jqXHR) {

},
onFail: function(jqXHR, textStatus, errorThrown) {
    alert('error');
    console.log(jqXHR, textStatus, errorThrown);
},

});

});
</script>

و ملف الباك ايند

<?php
//action.php

require("../includes/db.php");

$input = filter_input_array(INPUT_POST);

$translation =  $input["translation"];


if($input["action"] === 'edit')
{
    $query1 = " UPDATE lang  SET translation = '$translation' WHERE id = '".$input["id"]."' ";
    $result = $conn->query($query1);
   // mysqli_query($conn, $query1);
if ($result){
    echo done;
}
else {
    echo $conn->error;
}
}

echo json_encode($input);

?>

عند تعديل القيمة يظهر الخطأ التالي

'parsererror' SyntaxError: Unexpected token '<', "<br />
<b>"... is not valid JSON

علما بأن اي تعديل يتم اضافته عادي في قاعدة البيانات 

هل من اقتراحات؟

Recommended Posts

  • 1
نشر

احذف شرط ال result

حضرتك هو مش فاهم ايه done دي و بيحاول يربطها مع ال json مش عارف فبيديك خطأ

if ($result){
    echo done;
}
else {
    echo $conn->error;
}
}

 

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...