adding and retreiving

Javascript related discussion or help, including AJAX and jQuery.

Re: adding and retreiving

Postby Hyper » Sat Jul 24, 2010 6:59 pm

wide_load wrote:then you cheated :lol:

Well it's easier for beginners, I use it too because I use jQuery effects too so why not make it easier while I already have jQuery included.. :P
Btw, what's the example code of AJAX in plain JS(well the way that isnt "cheating")
Karma++; me if I helped! :roll:
GameZ4Free::playGames();

"There are 10 kinds of people, those who understand binary, and those who do not."
^^ I'm the kind that doesn't understand binary, but understands the joke ;)
User avatar
Hyper
Top Contributor
 
Posts: 934
Joined: Fri Nov 06, 2009 7:08 pm
Online: 6d 4h 31m 50s
Karma: 14

Re: Re: adding and retreiving

Advertisment

Advertisment
 

Re: adding and retreiving

Postby Tino » Sat Jul 24, 2010 7:15 pm

An example. Say you have a text file containing some very simple text. On a page you have a div (or whatever), that disappears and gets replaced by the contents of the text file when clicked upon. You could do that using this function:

  1. function loadText() {
  2.     if (window.XMLHttpRequest) {
  3.         obj = new XMLHttpRequest();
  4.     } else {
  5.         obj = new ActiveXObject("Microsoft.XMLHTTP");
  6.     }
  7.  
  8.     obj.onreadstatechange = function() {
  9.         if (obj.readyState == 4 && obj.status == 200) {
  10.             document.getElementById("someElement").innerHTML = obj.responseText;
  11.         }
  12.     }
  13.     obj.open("GET", "file.txt", true);
  14.     obj.send();
  15. }


This is pretty much the first thing you learn about AJAX, :) (Can't be bothered to explain it all) If I remember correctly, W3Schools uses pretty much this same example to 'teach' AJAX. So you can look there for more information if you like.
The below statement is false.
The above statement is true.

CodeCanyon
There are some pretty cool items over here, you should check them out.

There are 10 kinds of people, those who understand binary, and those who do not.
User avatar
Tino
Moderator
 
Posts: 1060
Joined: Wed Apr 22, 2009 1:28 pm
Location: The Netherlands
Online: 5d 13h 42m 14s
Karma: 10

Re: adding and retreiving

Postby Hyper » Sat Jul 24, 2010 8:58 pm

Tino wrote:This is pretty much the first thing you learn about AJAX, :) (Can't be bothered to explain it all) If I remember correctly, W3Schools uses pretty much this same example to 'teach' AJAX. So you can look there for more information if you like.


Thanks tino :)
Karma++; me if I helped! :roll:
GameZ4Free::playGames();

"There are 10 kinds of people, those who understand binary, and those who do not."
^^ I'm the kind that doesn't understand binary, but understands the joke ;)
User avatar
Hyper
Top Contributor
 
Posts: 934
Joined: Fri Nov 06, 2009 7:08 pm
Online: 6d 4h 31m 50s
Karma: 14

Re: adding and retreiving

Postby wide_load » Sun Jul 25, 2010 4:01 pm

jquery effects are also cheating :lol:

The problem is that while jquery is a very good library, it stops people from learning real javascript.

I wrote my own versions of the effects i wanted and and use them instead.

Plus a lot of people just use one effect from the library, and loading all of the other functions when they are not used cant be good.
Image
User avatar
wide_load
Top Contributor
 
Posts: 5375
Joined: Thu Aug 13, 2009 1:04 pm
Online: 12d 14h 21m 3s
Karma: 43

Previous

Return to AJAX/Javascript

Who's online?

Users browsing this forum: No registered users and 1 guest