2010-07-28 10:36 阅读 73


If possible, how can I get (and post) data from a mysql database using javascript? I know I can use php and other languages, but I just need to know if this is possible with javascript?

Thanks in advance.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

7条回答 默认 最新

  • 已采纳
    douzhi1919 douzhi1919 2010-07-28 10:38

    That's not possible with Javascript. I could not find this with server-side javascript too.

    Not sure about your exact requirement, but you can use Ajax to interact with database though some server side language.

    点赞 评论 复制链接分享
  • dongqiabei7682 dongqiabei7682 2010-07-28 10:39

    it is not possible, javascript is executed on the client.

    you could make the javascript call something on the server (e.g. php script) that access the database though.

    点赞 评论 复制链接分享
  • doulu0266 doulu0266 2010-07-28 10:45

    If by Javascript you mean NodeJS on the server, this project might interest you - however the answers above are correct if you are talking about Javascript running inside a browser or other container.

    If you want to run a vanilla javascript (for the concurrency speed) inside your own engine, I recommend looking at NodeJS and then using the NodeJS MySQL Native Driver that I linked above.

    点赞 评论 复制链接分享
  • dpoppu4300 dpoppu4300 2010-07-28 10:47

    Judging from the "iPhone" and "Android" tags, I guess, you are trying to access the local storage databases on these platforms.

    1. They don't use MySQL, but SQLite.
    2. How you access them from the mobile browsers is described in the W3C draft documents for the local storage: for the local storage API or for the SQL API. It should be roughly the same API on iOS and Android since both of them use the Webkit browser engine.
    点赞 评论 复制链接分享
  • doulin6761 doulin6761 2010-07-28 11:11

    The Web SQL database API isn’t actually part of the HTML5 specification, but it is part of the suite of specifications that allows us developers to build fully fledged web applications, so it’s about time we dig in and check it out. Some examples are here

    点赞 评论 复制链接分享
  • doushang8846 doushang8846 2010-08-03 10:22

    Do remove the tags iphone and android from this question. the tags are not relevant.

    And only with javascript you cant accompolish this task , GET and POST request can be handled only by server side scripting languages like php.

    Refer :

    点赞 评论 复制链接分享
  • doubu2730 doubu2730 2010-08-03 10:38

    javascript can get database from server if use AJAX , only a way is AJAX

    点赞 评论 复制链接分享