Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ajax Suggest

 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your server set up to execute asp or php?

Eric
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Placeholder message 'cuz I want to see how this one pans out: morbid curiosity.)
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meh; watching is too hard. I get too much email as it is. Is "meh" a word yet?
 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm, yes.
 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Ummm, yes.


Ok. So can you tell me how to do that please?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Morbid curiosity satisfied.)
 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One request == one response.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need more data, consider returning JSON (or XML if you must).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic