aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Ajax Suggest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax Suggest" Watch "Ajax Suggest" New topic
Author

Ajax Suggest

Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
hi,

There is an example on w3schools in which Ajax Suggest Code is given.

Following files are used for said example....
1. One HTML file.
2. A Java Script File
3. An ASP file which contains suggestions in an array.

From this asp file they are trying to fetch Suggestions as per key is pressed.

After i followed all the instructions,
problem is that whenever i type any alphabet, whole ASP code is getting attached
with suggestion area.
And i've also tried with PHP file instead of ASP but still, result is same.......

I've tried it on Chrome, IE7 and FireFox....

Please help....

Ref link : http://www.w3schools.com/Ajax/ajax_source.asp
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Is your server set up to execute asp or php?

Eric
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(Placeholder message 'cuz I want to see how this one pans out: morbid curiosity.)
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
David Newton wrote:(Placeholder message 'cuz I want to see how this one pans out: morbid curiosity.)


You could always click the watch button. Also UseRealWords because 'cuz is not a word. :)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Meh; watching is too hard. I get too much email as it is. Is "meh" a word yet?
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
Eric Pascarello wrote:Is your server set up to execute asp or php?

Eric


Not actually.

I dont have any server around here. I'm just doing it on my local machine.

But is that the cause for my problem...?? Do i have to setup some server to execute
ASP or PHP....?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

Ummm, yes.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
Bear Bibeault wrote:Ummm, yes.


Ok. So can you tell me how to do that please?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

Can't help you with ASP as I don't use Windows. Enabling PHP in Apache is fairly easy on OS X -- so I imagine it'd be pretty much the same elsewhere.

A google search should give you what you need.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you're just trying things out you don't necessarily need a back-end language, you can return static data.
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
David Newton wrote:If you're just trying things out you don't necessarily need a back-end language, you can return static data.


This is the javascript file.....



And this is getHint.asp



So, now i just want to print static data like Mr. David said.....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

You can't do that with ASP. If you want to serve ASP, you'll need to set up an ASP server. Plain and simple. No other way around it.

If you want to serve a static file, you'll need to create a text file with the static text that you want returned. No ASP. No PHP. No code of any type. Just text.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(Morbid curiosity satisfied.)
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
Bear Bibeault wrote:You can't do that with ASP. If you want to serve ASP, you'll need to set up an ASP server. Plain and simple. No other way around it.

If you want to serve a static file, you'll need to create a text file with the static text that you want returned. No ASP. No PHP. No code of any type. Just text.


Now i'm using JSP instead of ASP or PHP and these files are put inside eclipse project.
Now i'm getting what is expected....

But my new question is....

As we are returning the responseText in this Javascript Function....



Is there such rule in AJAX that the responseText will be returned only once...??
I mean if i want to return Multiple results as various responseText....
Can we do that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

One request == one response.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you need more data, consider returning JSON (or XML if you must).
 
jQuery in Action, 2nd edition
 
subject: Ajax Suggest