volosoft / jtable

A JQuery plugin to create AJAX based CRUD tables.
http://www.jtable.org
1.1k stars 506 forks source link

Invalid JSON primitive #2215

Open shyjuvs opened 5 years ago

shyjuvs commented 5 years ago

I am using jtable with ASP.NET MVC. jtable version is 2.3.0. MVC is 4.0. When try to add a new record, I get the error " Invalid JSON primitive". When I try directly using ajax post and send the data using JSON.stringify(), this works. Any idea what is the issue?

image

image

ismcagdas commented 5 years ago

@shyjuvs you need to send your data in Json format I guess, something like this;

{ "userEmailAddress" : "test@test.com"}

shyjuvs commented 5 years ago

@ismcagdas When we use jTable, there is no option that we can specify the data. It is submitted internally. As I mentioned, if I directly post using ajax and specify the data after JSON.stringify, it works.

misterparsons commented 5 years ago

Integration with legacy systems always puts the burden on the new integration. JTable used the add record dialog which it serializes and sends via POST to the server. It expects a suitable structure JSON object reply. If you need to change either or both of these interfaces you need to write it yourself. Rather than just supply a URL for the addAction, supply your own deferred function see documentaion This function can gather the necessary information, JSON.stringify it, send it via ajax to your legacy system, and translate the result back to JSON object suitable for jTable.