Using API call that I have instead fot a database using Generator ?
Using API call that I have instead fot a database using Generator ?
samsamtest
Posts: 52Questions: 15Answers: 1
Using API call that I have instead fot a database using Generator ?
Is that posible...
Kund Regards
Sam
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I'm afraid I don't understand what you are looking for here. Could you elaborate a bit please?
Thanks,
Allan
OO sorry, If now I want to use a Post (API )call and get the data to a datable that I have created on Generator. Is that easy to do. ?
POST rather than GET? Yes, you can send a POST request as show in this example.
Allan
HI,
I have been successful to get data to my tables from database mssql.
But I don't understand how I can add a Get and**** Post API call so it can show on the table to.
Is it posible to get an example how I can do that ?
Thanks,
Kind Regards
Sam
API = Rest API
DataTables will do a GET by default and Editor a POST by defailt. If you want to use different verbs, this example shows how it can be done.
Allan
Hi, okay thanks.
I don't understand where should I add the** Rest URL** where ?
I have used the generator to create the file.
Kinde Regards
Sam
You need to modify the
table.{name}.js
file that Generator created.ajax
has the full reference documentation for the Editor Ajax options.Allan
HI thanks,
I have tried to change that file.
The problem is that it still get the data from the db..
Is some ready code example that I can check ?
Thanks.
Kind Regards
Sam
I gave an example link above. Can you show me your code or even better, give me a link to the page showing the issue so I can help debug it?
Allan
Hi Thanks,
I was able to solve it.
I hade to add a Content-Length
It works now :-)
I have another question. Edit buttons docent work I am geting this error:
dataTables.editor.min.js:10 Uncaught Unable to find row identifier For more information, please refer to https://datatables.net/tn/14
This is the code am I missing something ?
Kind Regards
Sam
If you don't have a
DT_RowId
property in your JSON data source you need to use theidSrc
option to tell Editor which property to find the id in. This example shows that.Allan
Wow thanks, it works now :-)
I am now getting a 400 problem.
But hopefully I will solve it.
I guess I need to add the JSON parameter in edit something like this ore am I wrong ?
A 400 return indicates a bad request. Perhaps it isn't sending something that the server is expecting? What does the server-side need?
Allan
Hi, hanks for the help. When I want to post I need to send something like this.
How can I add this to the code ?
I did try this to, but it dose not work, still the same error.
I am getting now a 405 instead
I had to look that one up - couldn't rember a 405! Its "The method specificed is not allow". So your server isn't expecting a POST to
.../demo
(or whichever action URL it is that is triggering that error).Allan
Hi Allen, Thanks for helping me.
I have tried all day yesterday to fix this bit getting error still. I paused in the edit and went to create a post signal and get back information that I sent. Bit I either get 405 ore 400 error..
These first codes are done on a API program that I ca test that it works.
The code after are the ones that I have done and getting the errors..
** Code for send a update field from edit button. **
// Request (2) (POST http://a/CustomerSvc/REST/UpdateCustomer/demo)
** // This is when I want send values and get certain data back.
Request (POST http://adress/v2/BPOrderSvc/REST/GetOrderList/demo)
**
This is when I try to add it to datatbles and get an error to send a body post request.
This when I try to set up the edit button and get an error.
Okay - so your jQuery Ajax calls have a few differences. For example it uses:
In Editor the equivilent would be:
Note the use of
ajax.data
as a function. That is to allow Editor to add its properties to the object rather than just having a static object.Allan
thanks,
I am still getting 405 error..
Hi the api dosent support
f(isset($_SERVER['HTTP_ORIGIN'])){
header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN'] . "");
Can I disable this from the DataTables or do I need to add it the API
I'm afraid I don't understand. That's PHP code - I'm not clear on how that effects the API.
The key here is to figure out the difference between your working jQuery call and your not working DataTables configuration. Can you show me the two now that you've updated it?
Allan
Hi okay,
**So this is my code for datable:
**
**And this is the working code:
**
<?php
I am basically trying to change etc but still no luck
I don't see the header information or anything else configured in the
ajax
configuration. You have it for the DataTable Ajax configuration, but not Editor. You'd need to add it to each of the create/edit/remove options as well since Editor's Ajax call is separate from DataTables'.Allan
Hi sorry I don't under stand, In this case I am not going to use the edit delete and update.. If I don't fill that in dose it mean that the post won't function ?
Maybe I should use curl instead ? what do you think ?
ON Firefox I get this error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http:/my/adress/v2/BPOrderSvc/REST/GetOrderListByFile/demo. (Reason: CORS preflight channel did not succeed)
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://my/adress/v2/BPOrderSvc/REST/GetOrderListByFile/demo. (Reason: CORS request did not succeed)
In your Editor configuration it should contain:
Likewise for
create
.Allan
Hi so after some testing I now that the API docent accept Client Side.
what do I add if the signal needs to go server side and where do I and the "crossDomain": true, and "processData": false,.