[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Can I test ajax if I don't have any database or any server. I just run local

Tony Johansson

2/28/2015 11:20:00 PM

I just wat to text how it works from javascript or jQuery.
Is this possible or impossible?

//Tony
8 Answers

Thomas 'PointedEars' Lahn

3/1/2015 1:53:00 AM

0

Tony Johansson wrote:

> I just wat to text how it works from javascript or jQuery.
> Is this possible or impossible?

<http://www.catb.org/~esr/faqs/smart-question...

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.

Michael Haufe (\"TNO\")

3/1/2015 4:06:00 AM

0

On Saturday, February 28, 2015 at 5:21:03 PM UTC-6, Tony Johansson wrote:

[From subject line]:
> Can I test ajax if I don't have any database or any
> server. I just run local

> I just wat to text how it works from javascript or jQuery.
> Is this possible or impossible?


If you're on Windows create a localhost site in IIS[0], then test your queries against that. You may have to enable the IIS feature in the control panel first[1].

Alternatively, if you're using a decent IDE it will provide similar functionality.

[0] <https://support.microsoft.com/kb/323972...
[1] <http://www.iis.net/learn/install/installing-iis-7/installing-iis-on-windows-vista-and-win...

Tim Streater

3/1/2015 9:15:00 AM

0

In article <mctifg$q5r$1@dont-email.me>, Tony Johansson
<johansson.andersson@telia.com> wrote:

>I just wat to text how it works from javascript or jQuery.
>Is this possible or impossible?

Easy enough on a Mac which comes with the necessary software already
installed. Database is not relevant. You use your own machine as the
server.

--
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689

JJ

3/1/2015 11:36:00 AM

0

On Sun, 1 Mar 2015 00:20:00 +0100, Tony Johansson wrote:
> I just wat to text how it works from javascript or jQuery.
> Is this possible or impossible?
>
> //Tony

That depends on what you mean by local.

If you meant to run it from local web server using http:// or https://, then
yes you can.

If you meant to run it directly from the file system using file://, then no.
Most web browsers don't allow the file: protool to be used with AJAX (at
least by default). I don't know about Node.js, though.

Denis McMahon

3/1/2015 2:22:00 PM

0

On Sun, 01 Mar 2015 00:20:00 +0100, Tony Johansson wrote:

> I just wat to text how it works from javascript or jQuery.
> Is this possible or impossible?

You can create json or xml documents and request them with ajax requests.
But you'll need a server, because ajax talks to a server.

What you don't need for ajax is a database.

--
Denis McMahon, denismfmcmahon@gmail.com

Evertjan.

3/1/2015 3:04:00 PM

0

Denis McMahon <denismfmcmahon@gmail.com> wrote on 01 mrt 2015 in
comp.lang.javascript:

> On Sun, 01 Mar 2015 00:20:00 +0100, Tony Johansson wrote:
>
>> I just wat to text how it works from javascript or jQuery.
>> Is this possible or impossible?
>
> You can create json or xml documents and request them with ajax requests.
> But you'll need a server, because ajax talks to a server.

While the x in Ajax stand for xml,
any file can be requested and streamed,
as long as browser security restrictions are not compromised.

var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'justafile.txt', true);
xmlhttp.send();

Json and xml are just ways such files can be structured.

> What you don't need for ajax is a database.

Indeed, also no swimming pools.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Tim Streater

3/1/2015 5:26:00 PM

0

In article <mcv7a9$dos$2@dont-email.me>, Denis McMahon
<denismfmcmahon@gmail.com> wrote:

>On Sun, 01 Mar 2015 00:20:00 +0100, Tony Johansson wrote:
>
>> I just wat to text how it works from javascript or jQuery.
>> Is this possible or impossible?
>
>You can create json or xml documents and request them with ajax requests.

No you don't. What you are requesting is *data*, which can be in any
format as long as the two sides agree on what the format is.

>But you'll need a server, because ajax talks to a server.
>
>What you don't need for ajax is a database.

Both correct. The server can be local.

--
"Please stop telling us what you feel. Please stop telling us what your
intuition is. Your intuitive feelings are of no interest whatsoever,
and nor are mine. I don't give a bugger what you feel, or what I feel.
I want to know what the evidence shows." -- Richard Dawkins

Denis McMahon

3/2/2015 10:14:00 AM

0

On Sun, 01 Mar 2015 17:26:10 +0000, Tim Streater wrote:

> In article <mcv7a9$dos$2@dont-email.me>, Denis McMahon
> <denismfmcmahon@gmail.com> wrote:
>
>>On Sun, 01 Mar 2015 00:20:00 +0100, Tony Johansson wrote:
>>
>>> I just wat to text how it works from javascript or jQuery.
>>> Is this possible or impossible?
>>
>>You can create json or xml documents and request them with ajax
>>requests.
>
> No you don't. What you are requesting is *data*, which can be in any
> format as long as the two sides agree on what the format is.

Yes he can. OP can do other things as well, but OP _CAN_ do as I
suggested for the purposes of testing javascript / jquery ajax.

I didn't say that was the only thing he could do.

Technically you're just requesting a response, which may or may not
include a body, but unless you want to write your own parser to convert
the body you're sending from your server into data for your javascript to
use on the client, json and xml tend to be the two formats that javascript
can process natively.

Having said that, you can eg send a b64 encoded jpg image and:

document.getElementById(img_id).attr("src", "data:image/jpg;base64," +
data);

This may well work for other media types such as music files, but richard
should note well that I have no intention of helping him with any such
project!

--
Denis McMahon, denismfmcmahon@gmail.com