Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Support
  • Code University
  • Basic Ajax
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
  • Pages:
  • 1
  • 2
Basic Ajax
Tweet Topic Started: Jan 12 2009, 11:58 PM (386 Views)
Vitality Jan 12 2009, 11:58 PM Post #1
Member Avatar
Tabula Rasa

Posts:
784
Group:
Former Staff
Member
#320
Joined:
Jul 26, 2008
I am being taught this privately by somebody else, but they are quite busy (and I completely understand), so it is moving sort of slow, but more importantly I think it would be great to have two different angles on it because the person I am learning from is teaching me in jQuery. If it is easier to teach it through jQuery, go ahead by all means. I'll make sure different things are being covered.

So far I know what AJAX does. It is asynchronous so it is working behind the scenes and can perform what you tell it to without altering the contents of your page. Since it is asynchronous, it makes everything seem quick, effortless and smooth. We haven't reached much else yet. We're covering the concept of it and what exactly is happening when AJAX is in use.

First thing is first. Some syntax explanation would be most helpful, and as a simple start, I was trying to change up the code Choco used in the video tutorial, but have been unsuccessful. I was trying to use a similar concept, but grab different data from different pages.

Thanks to who teaches :D
Offline Profile Goto Top
 
HolySavior Jan 13 2009, 02:14 AM Post #2
Member Avatar
Modifying The World Around You

Posts:
2,488
Group:
Distinguished Coder
Member
#7
Joined:
Jul 2, 2008
Coding language
Everything
i will write up a jQuery AJAX tutorial tomrrow/later today. i will try to base it off my lastes postes code that can be put in sidebar. so it should be easy to understand.
Offline Profile Goto Top
 
Vitality Jan 13 2009, 07:53 PM Post #3
Member Avatar
Tabula Rasa

Posts:
784
Group:
Former Staff
Member
#320
Joined:
Jul 26, 2008
Okay, thank you! Much appreciated :D
Offline Profile Goto Top
 
HolySavior Jan 13 2009, 07:57 PM Post #4
Member Avatar
Modifying The World Around You

Posts:
2,488
Group:
Distinguished Coder
Member
#7
Joined:
Jul 2, 2008
Coding language
Everything
was pretty busy today. i will try to write one up asap. im thinking thursday but that can change.
Offline Profile Goto Top
 
Vitality Jan 13 2009, 08:32 PM Post #5
Member Avatar
Tabula Rasa

Posts:
784
Group:
Former Staff
Member
#320
Joined:
Jul 26, 2008
Whenever you can is fine. I understand.
Offline Profile Goto Top
 
Aegis Jan 14 2009, 07:05 AM Post #6


Posts:
97
Group:
Member
Member
#4
Joined:
Jun 10, 2008
Coding language
None
Code:
 
function XHR(type, link) {
this.link = link;
this.type = type || "GET";
if(window.XMLHttpRequest)
this.request = new XMLHttpRequest();
else if(window.ActiveXObject)
try {
this.request = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
this.request = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
}
}
return this;
}
XHR.prototype = {
open: function(fn) {
this.request.open(this.type, this.link, true);
this.request.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200)
fn.apply(this);
}
return this;
},
send: function(params) {
if(this.type.toLowerCase() == "post") {
this.request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
this.request.setRequestHeader("Content-length", params.length);
this.request.setRequestHeader("Connection", "close");
}
this.request.send(params || "");
}
}
// Example
var request = new XHR("GET", "http://zbcode.com/index/");
request.open(function() {
alert(this.responseText);
}).send();
That's what I use for AJAX. Seems to work in every major browser, and gets the job done well. However, I think I may remove this.status == 200 from the if statement so it can be used within the function instead.
Anyway, I find (or found, because it doesn't seem easier anymore) it easier to learn things by reading, editing, and using pre-existing resources.
Offline Profile Goto Top
 
Agent Moose Jan 14 2009, 01:01 PM Post #7
Member Avatar
SMF for Free Moderator

Posts:
838
Group:
Former Staff
Member
#14
Joined:
Jul 9, 2008
That is interesting. I never thought of calling AJAx through functions like you did :P
You could call me Troy :P | The World of Moosey | Newest Blog: SMF for Free Spam Code

Current Project: Zetaboard Javascript Tester (click on the link in the Submenu)

ZetaBoard Javascript Tester Features:
- Code Test box
- Counts how many open brackets/parentheses and closed brackets/parentheses you have in your code to make sure that your code will work.
- New: Inspect Element
Offline Profile Goto Top
 
slayer766 Jan 14 2009, 01:33 PM Post #8
Member Avatar
Hello all

Posts:
1,653
Group:
Distinguished Coder
Member
#12
Joined:
Jul 9, 2008
Coding language
PHP
That's because Beta is unique. ^_^
Offline Profile Goto Top
 
Vitality Jan 15 2009, 08:28 PM Post #9
Member Avatar
Tabula Rasa

Posts:
784
Group:
Former Staff
Member
#320
Joined:
Jul 26, 2008
Wow, thank you Aegis, that's really great! Only thing is I'm not that great with the whole trial and error style. I become to confused. I'm the type who needs things defined, explained and all of that. I grow off that.
I mean I understand most of that, but it becomes too much of a blur, and I need some clarification on steps and syntax. :(
Offline Profile Goto Top
 
Kotton Feb 1 2009, 05:49 PM Post #10

Posts:
60
Group:
Banned
Member
#1,668
Joined:
Dec 1, 2008
HolySavior
Jan 13 2009, 02:14 AM
i will write up a jQuery AJAX tutorial tomrrow/later today. i will try to base it off my lastes postes code that can be put in sidebar. so it should be easy to understand.
any results on this? I'd like to learn from it it as well
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Code University · Next Topic »
Locked Topic
  • Pages:
  • 1
  • 2

Track Topic · E-mail Topic Time: 7:47 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy