2010-07-28 10:36
浏览 104


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.

图片转代码服务由CSDN问答提供 功能建议

如果可能,如何使用javascript从mysql数据库获取(和发布)数据? 我知道我可以使用php和其他语言,但我只需要知道这是否可以使用javascript?


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

7条回答 默认 最新

  • 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 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 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 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 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 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 2010-08-03 10:38

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

    点赞 打赏 评论

相关推荐 更多相似问题