/    Sign up×
Community /Pin to ProfileBookmark

[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

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 10.2010 — You need probably [B]AJAX[/B]

JavaScript can not "touch" the server (except, maybe, [I]reading[/I], say, a certain [I]and existent[/I] XML file), nor anything which is outside the client's browser. But, encapsulated in the [B]AJAX[/B] 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.
×

Success!

Help @sNagheenanajar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...