/    Sign up×
Community /Pin to ProfileBookmark

AJAX simulation available?

Is there any way to simulate the actions of an AJAX text file load function
on a local computer without being tied to the server? ?

I want to test the program I’m developing without having to be tied to the server during the debugging phase.

Later, I would then substitute a “real” AJAX load function on the server
when I felt all was working right with the program and had moved it to the server.

Or is the best way just to change the text file to a very long string
and load with a .js extension during the development phase?

I’m looking for a general loading function, not just MSIE specific,
so I could test layout and design on different browsers.

Opinions or recommendations anyone? ๐Ÿ˜ฎ

to post a comment
JavaScript

13 Comments(s) โ†ด

Copy linkTweet thisAlerts:
@aj_nscApr 21.2010 โ€”ย Download and install a server on your computer. I usually download MySQL, PHP, phpMyAdmin, and Apache separately and install them myself to create my own local server, but apparently XAMPP is popular.

Then you're computer will act as a webserver. You can set it up so that it runs the same way as your online host and then, with a little tinkering, you can develop websites and applications from scratch on your machine and when you're ready to put them online, just FTP them without ever changing anything in the code itself.
Copy linkTweet thisAlerts:
@JMRKERauthorApr 21.2010 โ€”ย Thank you. I'll look into that option. I did not know I could do that.

Just a quick question about that:


Is it very difficult to get a local server working or are there any pit-falls I should be made aware of?

Thanks again for the information.
Copy linkTweet thisAlerts:
@aj_nscApr 21.2010 โ€”ย Very easy with XAMPP (so I am told).

The only difference is, instead of specifying URLs like http://www.example.com (where example.com is your website) you'll use http://localhost

Once you get it up and running, you'll wonder how you ever lived without it.
Copy linkTweet thisAlerts:
@svidgenApr 21.2010 โ€”ย Also, see DOM Storage.

At least I [I]think[/I] that's what I'm thinking of ...
Copy linkTweet thisAlerts:
@rnd_meApr 22.2010 โ€”ย why not jsut use ajax to load it from the local folder?

that works fine in firefox,, and behaves the same on the web.

if you decide to use a web server, look into the "plain old webserver" add-on for firefox.

it doesn;t have as many options as apache or iis, but it will produce a localhost port.

while firefox is running and POW is enabled, you can test your site with any other browsers on your machine.

super easy to download and setup, you don't even need to reboot.
Copy linkTweet thisAlerts:
@JMRKERauthorApr 22.2010 โ€”ย why not jsut use ajax to load it from the local folder?

that works fine in firefox,, and behaves the same on the web.
[/QUOTE]


Thank for the information. I'll look into the FF "POW".

However, whenever I have used ajax on a local file, I get an error and the file does not get loaded. Is there something obvious that I'm missing? I thought ajax was only valid to get text on a server file. ?
Copy linkTweet thisAlerts:
@svidgenApr 22.2010 โ€”ย If the "application" is being run locally, you should be able to load local files with it. However, you will be unable to perform any write operations without installing some form of local server. That can be in the form of a full web server or a browser addon.

And, as I stated before, there's already a means for using browser SQL-like storage. Though, I think I was actually trying to think of Google Gears ...
Copy linkTweet thisAlerts:
@rnd_meApr 22.2010 โ€”ย 

And, as I stated before, there's already a means for using browser SQL-like storage. Though, I think I was actually trying to think of Google Gears ...[/QUOTE]



you are mixing up your bleeding edge tech.:

you describe html5's DOMstorage, aka globalStorage, localStorage, sessionStorage:http://en.wikipedia.org/wiki/DOM_storage

the sql thing is different, it's webDB using sqlLite: http://dev.w3.org/html5/webdatabase/

note that dom storage doesn't work from file:/// locations, so it's not really relevant to this topic,

Im not sure about webDB, but it probably needs a sever too
Copy linkTweet thisAlerts:
@svidgenApr 22.2010 โ€”ย ... I'm pretty sure I was thinking of Google Gears or DOM storage:

Web storage currently provides an associative array data model where the keys and values are both strings. An additional API for accessing structured data, perhaps based on SQL, is being considered by the W3C Web Applications Working Group.[/QUOTE] -- Wikipedia


note that dom storage doesn't work from file:/// locations, so it's not really relevant to this topic,[/QUOTE]

fair enough.
Copy linkTweet thisAlerts:
@sohguanhApr 23.2010 โ€”ย Is there any way to simulate the actions of an AJAX text file load function

on a local computer without being tied to the server? ?
[/QUOTE]


If you really want a *FREE* server and no need to get through the hassle of installing Apache web server etc on your local PC, there is one option. Around year 2008 Google release something called Google AppEngine. Basically it provide web hosting for developer account.

For your need, Google AppEngine should serve well. It is *FREE* anyway. But once your site traffic get heavy, you may need to pay monies. For your case if it is just testing, Google AppEngine is perfect.

Basically you register an account with Google AppEngine. Then you will be allocated a URL that you have named it during your registration. E.g you register your application as testing123, then Google will give you testing123.appspot.com for free.

The downside is when you put files into your Google AppEngine developer account, it can only support Java and Python (don't ask me why not Perl or PHP). It seems Google is supporting Python in an "implicit" manner.

Voila you have your "server"!!! Google will take care of on the nitty gritty details of load-balancing, infrastructure, hardware etc etc issues behind the scenes for your URL. Ain't that beautiful?

But first you need to be Java or Python proficient. I was "forced" to learn Python due to the language restriction imposed by Google AppEngine. I can do Java but since I like challenges, I decide to go the Python way for my back-end routing scripts and uses Java for my applets on display :p
Copy linkTweet thisAlerts:
@JMRKERauthorApr 23.2010 โ€”ย Thanks to all who have given me advice. ?

Looks like I'll need to put on my reading glasses and get to work evaluating the possibilities. :p

My original intent was to just have a function that would * act * as an ajax function to load a text file.

I just wanted to load a text file from a local computer,

originally without using a server, that could be used on different browsers.

Once I had the text, I have been able to create an array of the information

with a simple .split() command.

I don't know enough about why the developers of JS did not include some read/write ability (other than a cookie),

but I assume it has to do with some security actions. ?

Most of the comments have pointed to a server solution ... :eek:
Copy linkTweet thisAlerts:
@rnd_meApr 23.2010 โ€”ย 
My original intent was to just have a function that would * act * as an ajax function to load a text file.[/QUOTE]


in that case, make a wrapper loading function.

if your orig function is called "myAjax", make a new one, "localIO".

by changing one variable at the top of your script, you can toggle between the two.


[CODE]debug=true;
// ...
function getDataMethod(){
return debug ? localIO : myAjax ;
}[/CODE]


you can then even clobber your normal function with the local version to make it seamless project-wide:
[CODE]myAjax=getDataMethod();[/CODE]

just keep the expected arguments in order, and the two can work interchangeably.

you could probably automate the whole thing by setting debug after examining the page's url with a regexp...
Copy linkTweet thisAlerts:
@JMRKERauthorApr 23.2010 โ€”ย Thanks 'rnd me', that almost sound too simple.

I'll give it a try and let you know my progress.

?
ร—

Success!

Help @JMRKER 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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