SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is XMLHttpRequest only usable with webserver?

    I have a server running that is listening on a TCP/IP port for XML. Based on the XML received the server does some processing and returns an XML blob.

    I currently connect via sockets using php.

    Is it possible to use XMLHttpRequest instead or is that intended only for web servers as the server end?

    TIA

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    XMLHttpRequest sends the same kind of request your browser sends when you type a URL. It probably expects standard HTTP headers back (like a Content-Type header and a status code like 200 OK).

    So if your server can parse HTTP requests:

    Code:
    GET /ajax-requested-page
    Host: www.example.com
    And send back HTTP responses in addition to the XML blurb
    Code:
    Date: Wed, 20 Aug 2008 07:06:47 GMT
    Server: Apache/2.0.46 (Red Hat)
    Cache-Control: private
    Pragma: private
    Keep-Alive: timeout=2, max=100
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=ISO-8859-1
    
    200 OK
    
    XML Content
    Then it'd work.

  3. #3
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no difference between AJAX XMLHttpRequest request and normal request for web-server. Web-server looks both of them as a similar kind of request.

  4. #4
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dan,

    Guess I'll be staying with sockets for now but at least now I know what has to be done to add http to our server. Added to the to-do list


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •