Tabledit failing to send post request

I recently integrated tabledit into a webpage, following various examples. However, the plugin is not functioning as expected - nothing is being posted and the result is empty. I am unsure how to get the posting feature to work properly. Can you offer me some guidance?

Here is a basic script:

     <table class='table'>
  <thead>
    <tr>
      <th>Id</th>
      <th>Firstname</th>
      <th>Lastname</th>
      <th>Email</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Doe</td>
      <td>Doe</td>
      <td><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8c2c7c0c6e8cdd0c9c5d8c4cd86cbc7c5">[email protected]</a></td>
    </tr>
  </tbody>
</table>
<script>
  $('.table').Tabledit({
    url: 'index.php',
    columns: {
      identifier: [0, 'id'],
      editable: [
        [1, 'col1'],
        [2, 'col2'],
        [3, 'col3']
      ]
    }
  });
</script>

While everything seems simple and functional - with buttons for saving and deleting posts via AJAX - there are no fields or formdata present. How can I address this issue?

Answer №1

You seem to be missing the handlers declaration in your Tabledit definition.

If you need help, there are some examples available in the documentation.

Don't worry, I've gone ahead and added them for you.

$(document).ready(function() {

    $('.table').Tabledit({
        url: 'index.php',
        columns: {
            identifier: [0, 'Id'],
            editable: [
                [1, 'Firstname'],
                [2, 'Lastname'],
                [3, 'Email']
            ]
        },
        onSuccess: function(data, textStatus, jqXHR) {
            // handle success here
        },
        onFail: function(jqXHR, textStatus, errorThrown) {
           // handle errors here
        },
        onAjax: function(action, serialize) {
            // execute your XHR requests here 
            console.log("on Ajax");
            console.log("action : ", action);
            console.log("data : ", serialize);
        }
    });

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="82e8f3f7e7f0fbaff6e3e0eee7e6ebf6c2b3acb2acb2">[email protected]</a>/jquery.tabledit.min.js"></script>
<table class='table'>
   <thead>
      <tr>
         <th>Id</th>
         <th>Firstname</th>
         <th>Lastname</th>
         <th>Email</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>1</td>
         <td>Doe</td>
         <td>Doe</td>
         <td><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e747176705e7b667f736e727b307d7173">[email protected]</a></td>
      </tr>
   </tbody>
</table>

Answer №2

Simply make sure to return true upon the onAjax function call

$(document).ready(function() {
   
 $('.table').Tabledit({
        url: 'index.php',
        columns: {
            identifier: [0, 'Id'],
            editable: [
                [1, 'Firstname'],
                [2, 'Lastname'],
                [3, 'Email']
            ]
        },
        onSuccess: function(data, textStatus, jqXHR) {
            // Handle success here
        },
        onFail: function(jqXHR, textStatus, errorThrown) {
            // Handle errors here
        },
        onAjax: function(action, serialize) {
            // Initiate XHR request here 
            console.log("on Ajax");
            console.log("action : ", action);
            console.log("data : ", serialize);
            return serialize;
            **return serialize;**
        }
    });

});

Answer №3

To customize your cells, insert the following code:

<td class='tabledit-view-mode' style='cursor: pointer; background-color: #DEE1E8;'>
<span class='tabledit-span' style='display: inline;'>YOUR CELL DATA</span>
<input name='VAR_NAME' disabled='' class='tabledit-input form-control input-sm' style='display: none;' type='text' value='YOUR CELL DATA'></td>

When you click on it, Tabledit will transform the display to input mode, providing access to your variables.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Identifying the moment an element reaches the top of the viewport

Seeking guidance on using JS/jQuery to accomplish the following tasks: Detect when a paragraph intersects with a fixed top navigation bar as the user scrolls through a lengthy article Retrieve the first line of the paragraph and iterate through its charac ...

Guide on incorporating data from JSON into a table with JavaScript

Following a tutorial from this source, I am working on creating a real-time table using PHP and AJAX. The PHP file sends back JSON-formatted values: { "retcode" : "0 Done", "trans_id" : "187472", "answer" : [ { "Country" : "US", "Digits" : "5", "Datetime ...

Is there a benefit to using middlewares instead of the standard built-in functions in Express.js?

Express.js offers a wide range of middlewares that replace built-in functions. One example is body-parser, which parses HTTP request bodies, replacing the built-in function express.bodyParser. body-parser replaces the built-in function express.bodyParse ...

Utilizing Draft JS to dynamically insert text in the form of span

I'm utilizing Draft.js with its mentions plugin. Occasionally, I'd like users to input a mention not by choosing from a dropdown menu, but by typing something like, for example, "@item" or "@item". In the function below, you can observe that if ...

Copying the value of a datagrid column in EasyUI is a simple task that can be

<script type="text/javascript"> var tbIndex = undefined var tbData = undefined $('#dg').datagrid({ onClickRow:function(rowIndex,rowData){ tbIndex = rowIndex tbData = rowData }, on ...

What is the best way to apply a mask to a textbox to format the date as MM/yyyy using a mask

In my asp.net application, I have a TextBox for entering Credit card date (month & year only). I tried using the 'TextBox with masked edit extender' and set Mask="99/9999" with Mask Type="Date. However, it is not working as expected - it only wor ...

Using Promise to manipulate objects and arrays returned from functions

https://i.stack.imgur.com/jvFzC.png router.get('/', function (req, res, next) { var size = req.params.size ? parseInt(req.params.size) : 20; var page = req.params.page ? req.params.page>0 ? (size&(parseInt(req.params.page)-1)) : ...

Having difficulty removing a specific item from Firebase Realtime Database in React Native

I am currently working on developing a mobile app that allows users to create teams and players and save them into a database. While I have successfully implemented the team creation functionality, I am facing challenges with the deletion of individual pla ...

Filtering Results Efficiently Based on Various Criteria in React

To view my project in action, please visit my sandbox here. Due to limitations, I am unable to paste all of the code directly here. The goal of my project is to create a tours filtration system based on multiple criteria. Each tour is represented as an ob ...

Using React: Implementing conditional checks within the render() method of functional Components

When working with my usual React class Components, I typically perform some checks within the render() method before returning conditional html rendering. However, when using a react functional component, I noticed that there is no render() method availabl ...

Crosswalk code unable to detect electronic devices

The implementation of a rails application involves the following code snippet: <div id="sourceSelectPanel" style="display:none"> <label for="sourceSelect"& gt;Change video source:& lt;/label> <select id=" ...

What is the method for selecting the "save as" option while downloading a file?

Imagine a scenario where you click on a link like this: <a href="1.txt">Download</a> After clicking the link, a save as window will appear. Is it feasible to utilize JavaScript in order to simulate button clicks within that window? Alternativ ...

Create a hover effect with an overlay on mouse hover

I'm struggling with achieving a specific effect. Whenever I hover the mouse over this element : <div class="process"> <h3 class="text-center">Process</h3> <ul class="row text-center list-inline wowload bounceInUp animated" ...

Using Three.js to shift an object toward a specific point on a line and adjust its orientation with lookAt

I am working with a cuboid (such as THREE.CubeGeometry 1x1x10) and I have a specific goal in mind: My objective is to position the cuboid at a certain distance from the origin, along the line connecting the origin and a given point I also want to rot ...

Failure when running npm start command in Nest js

After setting up a fresh Nest js on a new EC2 machine, I encountered an error when trying to run it for the first time. The error message indicated that the npm install process failed abruptly without any visible error: ubuntu@ip-172-31-15-190:~/projects/m ...

Creating a React NavBar with Bootstrap 4 and the <Link/> component

My goal is to create a customized Bootstrap 4 NavBar using the ReactJS <Link> component from react-router instead of the traditional <li> class. I've encountered some difficulties in building the component properly, as the ReactJS compone ...

Sending objects as parameters to a class in JavaScript - an easy guide

Having trouble passing a parameter to the class for handling AJAX errors. The initial function is as follows: function GetLastChangePass(UserId) { var field = { id: UserId, } var fieldStringified = JSON.stringify(field) $.ajax({ ...

Preventing Unauthorized Access: Redirecting to Login Page in Vue.js

Here is the code snippet I'm working with: <script> export default{ props:['idStore'], methods:{ addFavoriteStore(event){ $(function () { $(document).ajaxError(functi ...

Is there a way to dynamically change the title of a tab when new content is added to a minimized page?

Is anyone familiar with how websites like Facebook and Buzzfeed update their tab titles when there are multiple tabs open? I have noticed that sometimes they add a "(1)" or "(2)" to indicate changes on the page. Do they use JavaScript to achieve this eff ...

Obtain input from request payload in WCF/ADO.NET Data Service

Why are my parameters getting lost when I try to post to an ADO.NET Data Service? This is what my code looks like: [WebInvoke(Method="POST")] public int MyMethod(int foo, string bar) {...} Here's how I'm making the ajax call using prototype.js ...