Tabulator get an option to parse table from remote server like ajaxURL:"https://mysite/data.json" and download table data as json.
But don't let to upload json data to same or another server.
How can I do the upload function to my table?
This is a very open ended question as that depends on which type of server you are using.
The standard method would be to make an AJAX request to the server, usually a POST or PUT request depending on whether you were creating or updating data.
You would retrieve the data from tabulator using the getData method, which return s an array of row data objects.
var data = table.getData()
You can then use an ajax library of your choice. Browsers come with the built in Fetch API or you could use a 3rd party library like Axios
How you send the data to the server is up to you as you will have to put the code in on the server to process it, so you will set the property names etc that the data will need to be set against in the request.
Related
$.getJSON let us to get data from the file, is there any way to set data into the file? i have tried $.setJSON, but it shows me "$.setJSON is not a function".
You can't access the local file system using front-end Javascript. And there is no way on doing it.
What you can do is create a web server.
Send a request with the data in the server using AJAX
On the server, save the data by writing it on a file
That's pretty much it.
I have an sqlite3 database I need to render in the front-end of my application on a GET request. Currently, I am able to render the data as a JSON dump as shown:
if self.path == "/stuff" :
self.send_response(200)
self.send_header("Content-type:", "application/json")
self.wfile.write("\n")
json.dump(db.getAll(), self.wfile)
I have now created a stuff.html where I want to present the data. For example, loop through printing the JSON data to the screen.
Instead of just dumping the data, how would I pass and call the JSON data from the database?
You can directly fetch data from the database using the following link:
access database using javascript from frontend
Currently I have a working javascript/jquery file that makes a request to a php file to retrieve json data. This works great.
Some information is taken from the server and send back to the javascript/jquery.
So:
Request from js to exchange.php ==>
exchange.php access database and gets certain data
<=== response from exchange.php to jquery to send data to js
js uses data to make some changes to the website (changes phonenumber)
This has to be done as fast as possible. But after I have send the data to the js I want the same exchange.php log this data + some userdata to another database. For speed reasons I want to do this after the data is sent to the javascript. Is this possible?
Currently I just call the logging class after I echo'd json_encode(); But does it make a difference? Or will the json be send only after the whole php file has finished running?
I have a website with a form (currently it's plain HTML but we're switching to JQuery). The flow is like this :
Take in the user's inputs --- 5 integers
Make a call to a web service via REST
Run some calculations server side... and generate a JSON object
??? Now I have my result JSON object, but how do I get it to the client? Persist it?
??? Does the URL need to be the exact location of the JSON file? That would mean 100's
??? of JSON files in my web server's DIR.
D3.js on the client side, waits for the data to be present (via AJAX?).
var data; // a global
d3.json("path/to/file.json", function(error, json) {
if (error) return console.warn(error);
data = json;
visualizeit();
});
Once data is present, render for the client, and remove the calculator from the screen.
I'm having a tough time here, because I notice all AJAX requests need a URL.. but then does that mean I need to give a unique URL to each resulting JSON object? Doesn't that mean I need to persist that object?
I'd just like to have d3.js render my JSON object but unclear what are my options for where to put it.
How do I post parameter on d3.json?
Typically, you will pass some parameters via a javascript object or
a query parameter.
Basically, something like...
data = {}
data.var1 =5;
data.var2 =10;
var my_request = d3.xhr(url)
my_request.post(JSON.stringify(data), function(error,received)){
};
Or
d3.json(url+"?"+"var1=5&var2=10",function(error,received)){
}
Obviously, these form parameters can be parsed on the server easily. After the values are parsed on sever, the server can generate the new JSON using the form parameters that have been parsed.
Make sure that if you are running the script from a local page (or a page that is not on the website) that the server has the ability to allow cross origin (or domain) requests.
If you want to persist the data across multiple calls, you will probably have to to embed the callbacks, or use global variables.
I'm using a service called TrueFX that provides currency information based on HTTP request/response. I need to send the initial request to the base URL with username, and other parameters. The service responds with a session ID. A subsequent HTTP request is sent with the session ID and the instructions for output type (CSV or HTML). The second response provides an HTML table with the requested data.
The final destination for this data will be a chart via the JQPlot plugin for JQuery. JQPlot will accept an array instead of individual values to be plotted.
Questions:
Is it best to create the array of data using JQuery, plain ole Javascript or PHP?
Depending on response to above, how do I define the request to TrueFX, the TrueFX response containing currency data in HTML format? Is this just done through the $.ajax JQuery method?
How do I create and save the array for reference and use in my call to JQPlot?
Thanks so much for your advice, help and guidance.
First off I would recommend you work with the CSV format as it will be much easier to parse into an array of arrays for use in your chart (also data size will be much smaller). There are multiple CSV plugins for jquery that make this parsing pretty easy. Here is one I found real quick: CSV Plugin
You can use jquery's $.ajax to get the data from the remote service (using JSONP) and the CSV plugin to parse the returned data. Then you feed the resulting array of arrays into your chart.