开发者

How to connect to mysql database using only ajax and javascript?

开发者 https://www.devze.com 2023-03-20 22:37 出处:网络
I am trying to make an app using phone gap that makes users login in. I know how to connect to a mysql database using 开发者_高级运维php but I have no clue on how to connect to it using ajax. I hope s

I am trying to make an app using phone gap that makes users login in. I know how to connect to a mysql database using 开发者_高级运维php but I have no clue on how to connect to it using ajax. I hope someone could show how its done or if there is another way to connect to a mysql database in phonegap.

Thank You


You can't directly connect to MySQL database from client side.. This is not exactly correct (but I've heard some people doing similar with MongoDB).

Anyway, right approach for this is:

  1. You have to have a server side code (web service) with methods that actually connect to database, perform CRUD operations. This would be you application API.
  2. In client you use that API. If you are on Javascrip, using of jQuery is best.


This is not specific to Android.

Anyway, last time I checked, it wasn't possible to connect directly to MySQL via AJAX.

What you need is a back-end (in php, for example) that accepts connection via AJAX and then connects to MySql, processes the data and gives back the results via JSON, XML, plain text or whatever format you prefer.

0

精彩评论

暂无评论...
验证码 换一张
取 消