I have a WebSQL database, and am trying to connect to a PHP script, and dump that database into another one on the server.
How do I format the javascript / jquery in order to do that correctly?
I guess I am asking, how do I dump all of my data in my tables into my PHP script, so that it can update and insert the data into another database on the server?
I have no clue where to even begin with this.
The terminology in this question is a little confusing. If you're trying to copy the database from one location to another on the same server, you would only use PHP at most. This could also be done with just your sql administration.
If you are attempting to copy the database to a "Web SQL" database on a client (not a server), I've found a round-a-bout sort of way to accomplish this. I say round-a-bout because in my case I had to copy the database from the server to local client files (aka cross domain). In short:
1) Use PHP to create a json_encode version of your database from the server, using fwrite to create a .json file on the server
2) Using a php proxy to deliver the json data, make a jquery ajax call to the proxy, for the .json file you created
3) Use javascript to store the JSON data into the client's "web sql" database.
Related
So I have information i need to save. I am using a JavaScript object then I store the info in a JSON file.
But I want to put my project on a server and run it. but currently I am using fs to read and write data.
how would i do that on a server
You can have the JSON file in the server and read/write to it the same way you are doing locally, it makes no difference.
That said, I'd recommend using something like http://npmjs.com/package/json-server to make it work like an actual server API.
I want to set data in HTML local storage using Python (I am using Flask framework).
Do I need to use JavaScript?
You need to use JavaScript.
Python (server-side) knows nothing about JavaScript (client-side) where localStorage resides.
The easiest, however many times not the most efficient, way to approach the problem is
You have a JavaScript JS snippet running in your HTML page
This JS makes an AJAX request to the server-side Flask view. Try jQuery.getJSON()
Flask view returns JSON data
JS code receives the JSON and stores it in the localStorage
Alternative, if the amount of data is few bytes, you can pass it from the server-side to the client-side (JavaScript) using cookies.
I am looking for a way to save simple form data from a static web page without any server-side code. I've considered something like MongoLab via RESTful interface, but that would require including API credentials client-side and the saved data must be private. Any suggestions? Thanks.
you need to post you form data somewhere, so you must have a server listening for a http form submit, or alternatively use something like socket.io / WebSockets to send all the data to a server. You cannot write to a database from a user browser without contacting some server that will write the information to the database..
Hadn't thought of using a BaaS (back-end-as-a-service) provider like parse or stackmob, but that's the solution. Just hadn't thought of using it for a simple, static web page. I signed up for parse.com and was collecting data within five minutes!
I need to insert sample data into SQl server.
But i should use HTML,Javascript,JQuery,Ajax,XML only.
I can't use asp.net or php programming languages , because i will not use IIS for this project.
Is there any option to do this?
Hi,Is possible to connect to SQL from XML page.
You need to have a server side page to handle your ajax request where it will read the data coming from ajax request and send to the db.
If you do not want to use IIS, you can think about PHP as your server page which works on Apache server.
Is it possible to add a JavaScript variable in an SQL Server database database (run an SQL query or stored procedure)? If so, how?
With JavaScript only, no you cannot (unless you're using Node.js of course).
The point is, you'll need some server-side code to interact with your database. You can use JavaScript in the browser to make an Ajax call to a server-side script (PHP, Ruby, Python, ASP.NET, Node.js, etc.) that performs the interaction with the database.
You can not access the database from JavaScript. You need to send your data to PHP, Ruby on Rails or ASP.NET or whatever you are using to implement the back end.
You can use Ajax to post to a web service of some sort (or any other server side script) to pass the JavaScript value. The web service would access the database and save it...
Set value of variable in the hidden field and get value of that field at server side when submit form and save it into the database....
You can easily access a database from JavaScript in Node.js.
If you're doing it from the browser, you'll most definitely need some kind of mid-tier service which translates HTTP queries to the relevant database driver (you can write that in any language you want - PHP, JavaScript, ASP.NET, etc.).