dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Help me further understand client vs. server-side

  1. #1
    Join Date
    Nov 2010
    Posts
    23

    resolved [RESOLVED] Help me further understand client vs. server-side

    I understand the conceptual difference between client and server-side scripts but am still a little confused. Here is an example I'm working on that furthers my confusion.

    a) I have an XML file stored on the server (in the same directory as my HTML/js files) that I use a jQuery.get() to access and parse the file. The jQuery.get directly names the file to be accessed.

    b) Now, I want to create a list of all the filenames in a certain directory on the server. From what I understand I should do this on the client side (I'm using python) then pass the result as an HTTP response (I was planning on creating a json file with python that would be passed to the javascript).

    So my confusion lies in the a). It seems like to keep the appropriate server/client differentiation the javascript should just be saying "give me some XML" and my python script should respond with the appropriate file.

    But since in example a) javascript is directly accessing a server-side file why cant javascript loop through a directory on the server as well?

    Thanks for any insight.

    Samir

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    You need probably AJAX

    JavaScript can not "touch" the server (except, maybe, reading, say, a certain and existent XML file), nor anything which is outside the client's browser. But, encapsulated in the AJAX technique, it might send requests to a server-side file, written in a server-side language. That server-side code should do all the server-side job (searching files, sending queries to a DB, getting the response, etc.). When this job is ready, the server-side code sends back to the AJAX object a certain response, which is to be evaluated and used at the client side level by JavaScript.

    As far as I know, this is the safe and normal way to deal with the server, from the client's side point of view.
    Last edited by Kor; 11-10-2010 at 01:53 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles