AJAX Connect to a Server

Discussion in 'JavaScript' started by vitaminman, Oct 1, 2007.

  1. #1
    I am pretty confused as to how AJAX can send and receive data from a server. So I was wondering if somebody could explain it? Let's say that I already have an XMLHttpRequest set, called "ajax". How could I access a database using that and pull out some data?
     
    vitaminman, Oct 1, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Javascript can only send requests to the server and receive a response, but you need a server side script that accesses the database and handles the request. (This can be done with PHP/ASP/etc)

    Here's a quite simple tutorial.

    http://www.w3schools.com/ajax/default.asp
     
    nico_swd, Oct 1, 2007 IP
  3. vitaminman

    vitaminman Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well yeah I know that I need some type of server-side scripting, and I am using PHP to do that. I just don't know how I can get the data using the "responsetext" method, unless I echo all of the data from the server to the file, which seems messy.

    I'm looking over that tutorial now, though.
     
    vitaminman, Oct 1, 2007 IP
  4. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    #4
    temp2, Oct 2, 2007 IP