SitePoint Sponsor |
|
User Tag List
Results 1 to 11 of 11
Thread: Hello in ajax
-
Oct 21, 2008, 07:32 #1
- Join Date
- Oct 2008
- Location
- Banned
- Posts
- 506
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hello in ajax
Can someone give me example code of how to click a button then display on teh screen Hello World in ajax??
-
Oct 21, 2008, 08:01 #2
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think you may be confused as to what ajax actually is. here is what you asked for in Javascript?
Code javascript:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" media="screen" /> <style type="text/css"></style> <script type="text/javascript"> function addEvent(element, event, callback) { if (element.addEventListener) element.addEventListener(event, callback, false); else if (element.attachEvent) { element["e"+event+callback] = callback; element[event+callback] = function() { element["e"+event+callback](window.event); }; element.attachEvent("on"+event, element[event+callback]); } } // add the window.onload event addEvent(window, 'load', function() { // get the button var btn = document.getElementById('button'); // assign the onclick event to the button addEvent(btn, 'click', helloWorld); }); function helloWorld() { alert('hello world'); } </script> </head> <body> <input type="button" id="button" value="Hello world" /> </body> </html>
-
Oct 21, 2008, 08:14 #3
- Join Date
- Oct 2008
- Location
- Banned
- Posts
- 506
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What exactly is ajax. with a full explanation
-
Oct 21, 2008, 08:34 #4
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
http://en.wikipedia.org/wiki/AJAX
Google is your friend
-
Oct 21, 2008, 08:42 #5
- Join Date
- Oct 2008
- Location
- Banned
- Posts
- 506
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Whenever I google ajax it gives me tutorials and articles ;(
-
Oct 21, 2008, 08:44 #6
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Personally I think that is one of the best ways to learn. By example.
-
Oct 21, 2008, 09:01 #7
- Join Date
- Oct 2008
- Location
- Banned
- Posts
- 506
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I like to learn by coding it too. tutorials and articles are worthless
-
Oct 21, 2008, 13:03 #8
- Join Date
- Oct 2008
- Location
- Banned
- Posts
- 506
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
also i tihnk u misunderstood me. i tried out the code and all it is is an alert. I know how to do that lol. Im not a beginner programmer in JS. What I want is when I click a button for example on a new line or even next to the button is the words Hello to pop out of nowhere without reloading the page
-
Oct 21, 2008, 16:41 #9
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:<button type="button" onClick="document.getElementById('foo').innerHTML = 'Hello!';">Click Me!</button><span id="foo"></span>
-
Oct 21, 2008, 16:56 #10
- Join Date
- Oct 2008
- Location
- Banned
- Posts
- 506
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I know. That was my point. but I already found a tutorial on how to say hello world. Its in another thread I believe
-
Oct 21, 2008, 18:08 #11
- Join Date
- Jan 2007
- Location
- Christchurch, New Zealand
- Posts
- 14,729
- Mentioned
- 104 Post(s)
- Tagged
- 4 Thread(s)
The Bulletproof Ajax code archive starts off with a test ajax. The book is an excellent read too.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Bookmarks