can i get database value from jsscript

Discussion in 'JavaScript' started by property, Mar 5, 2011.

  1. #1
    can i get database value from jsscript
     
    property, Mar 5, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    You'll need php, or another server executed language.

    Even if it were possible, it would be utterly stupid to use. In that case, you would need to give the database information to the users, which is stupider than giving a locker with all your precious possessions, to a complete stranger, and not locking it.Even if you could hide your information, it would still be quite easy to tamper with the data, and it would probably take 5 minutes, before your whole database is truncated, or somehow else messed up.

    The answer is an obvious no.
     
    ssmm987, Mar 5, 2011 IP
  3. HungryMinds

    HungryMinds Active Member

    Messages:
    216
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    63
    #3
    Find Out AJAX Tutorials & Samples, They Will Help.
    You Can Use COMPLETE DATABASE Handling With AJAX.
    AJAX & JQUERY are Advanced Version Of JAVASCRIPT.
     
    HungryMinds, Mar 5, 2011 IP
  4. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #4
    This is done regularly using AJAX and is a process that is not at all uncommon within many of today's web apps.
     
    camjohnson95, Mar 6, 2011 IP
  5. gandalf117

    gandalf117 Active Member

    Messages:
    111
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    As ssmm987 said, getting data directly from the database with javascript alone is impossible and even if it was it would pose a great security risk.

    On the other hand you can use PHP to get the data from the database and then use Javascript to get the data from the PHP file. It's not the same as getting the data directly from the database but to the user it looks the same, because the page doesn't reload. The methods that allow this to happen are programmed is javasript and are called AJAX.
     
    gandalf117, Mar 7, 2011 IP
  6. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    youll need php you can then echo the value from php to javascript if youd like
     
    srisen2, Mar 7, 2011 IP
  7. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #7
    If you meant directly from a database, through javascript alone, then Yes it is possible. If you have a database on your computer and run a a javascript locally. This would be useful only for creating scripts for local database maintenance. It would also be useful when run over a local network.
     
    Last edited: Mar 7, 2011
    camjohnson95, Mar 7, 2011 IP
  8. vinoth.t

    vinoth.t Peon

    Messages:
    156
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Actually Database is in server side and your Java Script is in Client Side so you can't get the value. But you can do it by using Ajax concept where you can get server response by sending request through srcipt.
     
    vinoth.t, Mar 23, 2011 IP
  9. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #9
    A database can be either. As I said before, Javascript CAN connect to a database locally... but only when run locally as a script, on the same machine as the database... A database is merely a file, it's whether or not you have the permission to access it..
     
    camjohnson95, Mar 29, 2011 IP
  10. Jan Novak

    Jan Novak Peon

    Messages:
    121
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    0
    #10
    It is interresting. Please can you show me a code which do that?
    I suppose you don't wanna use cookies, arrays etc. I think there is no way how to connect with common browsers directly to RDBMS like Oracle, Sql Server, MySQL...

    Only one way which I know is ActiveX, which is available only at IE with low level security options or with FF when people have installed special plugin.

    Thanks
     
    Jan Novak, Mar 29, 2011 IP
  11. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #11
    camjohnson95, Mar 29, 2011 IP
  12. Jan Novak

    Jan Novak Peon

    Messages:
    121
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    0
    #12
    Jan Novak, Mar 29, 2011 IP
  13. sweetiee

    sweetiee Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    the answer is "YES" you can use AJAX technology where javascript calls for php function behind the scene - where you access your database
     
    sweetiee, Mar 29, 2011 IP
  14. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #14
    I completely agree, but it is possible. Could be useful for local database maintenance, reporting etc. Non-commercial type things...
     
    camjohnson95, Mar 29, 2011 IP