Ross
eCreations Staff
Posts: 1,768
|
AJAX
Feb 24, 2007 22:12:43 GMT
Post by Ross on Feb 24, 2007 22:12:43 GMT
So has anybody else around here used AJAX for anything? AJAX is basically using Javascript to send/retrieve information from the server. I've recently started trying to encorperate it into a project I have been working on and so far have found it to be fairly easy to use and it should be pretty useful. I'd be very interested in seeing someone elses work with AJAX though as mine has been bit of a case of making it up as I go along
|
|
|
AJAX
Feb 25, 2007 15:02:48 GMT
Post by FireIndy on Feb 25, 2007 15:02:48 GMT
No, but I have looked at it. It seems interesting, but I think Ill stick with PHP right now. I never did really like how Javascript goes. I mean the syntax. It just seems wierd.
|
|
ME!
Moderator
~Remanifesting-Eternal.~
Posts: 778
|
AJAX
Feb 25, 2007 23:44:24 GMT
Post by ME! on Feb 25, 2007 23:44:24 GMT
I actually used AJAX recently; It was for Enchant's Website..she didn't want to use Iframes. function getPage(url, objId) {
var call_page = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
call_page.onreadystatechange = function() {
loadpage(call_page, objId); }
call_page.open('get', url, true); call_page.send(null); }
function loadpage(call_page, objId){
if (call_page.readyState == 4 && (call_page.status == 200 || window.location.href.indexOf("http")==-1)){ document.getElementById(objId).innerHTML = call_page.responseText; } }
nothing fancy, but quite affective
|
|
|
AJAX
Feb 26, 2007 0:18:14 GMT
Post by Amused To Death on Feb 26, 2007 0:18:14 GMT
Being a n00b, i have to ask: What does that code do?
|
|
Ross
eCreations Staff
Posts: 1,768
|
AJAX
Feb 26, 2007 0:47:09 GMT
Post by Ross on Feb 26, 2007 0:47:09 GMT
Amused To Death, what the code Dre posted does is grabs the contents of another file (the file will depend on what link is clicked) and writes its contents to part of the page. And all that without the page having to be refreshed. Dre, looks good. With the one I'm doing, I'm looking at the possibilities of using the XML version to check if the code has returned certain information and then dealing with each piece returned seperately. For me, the biggest challenge has been handling javascript functions that need to be loaded and called after the AJAX request has been sent. You see, I'm using AJAX to submit a form and then depending which form is submitted, I want to load an external JS file which changes some of the text/links on the page, I just don't want this external js file to be sent to the page every time. I'm just wondering though, maybe it'd be easier if I grabbed the file contents as text and just wrote out the JS, not sure if that'd work though
|
|
ME!
Moderator
~Remanifesting-Eternal.~
Posts: 778
|
AJAX
Feb 26, 2007 1:37:36 GMT
Post by ME! on Feb 26, 2007 1:37:36 GMT
So Ross, what you want to do is when request is sent you want to write specific JS on to the web page? why not setup a function that when a form submit button is pressed it writes a specific JS file using a function. If you want those text/links to be more persistent, why not use cookies? and it reads the cookie and writes that JS file.
I'm not 100% sure what you want done, maybe a little more detail ? >.<
|
|
|
AJAX
Feb 26, 2007 10:09:20 GMT
Post by Shockeye on Feb 26, 2007 10:09:20 GMT
nice code, Dre. I haven't learnt AJAX. I'm still learning HTML and javascript. Beginning languages come first
|
|
Ross
eCreations Staff
Posts: 1,768
|
AJAX
Feb 26, 2007 12:18:04 GMT
Post by Ross on Feb 26, 2007 12:18:04 GMT
So Ross, what you want to do is when request is sent you want to write specific JS on to the web page? why not setup a function that when a form submit button is pressed it writes a specific JS file using a function. If you want those text/links to be more persistent, why not use cookies? and it reads the cookie and writes that JS file. I'm not 100% sure what you want done, maybe a little more detail ? >.< More detail would probably give away too much I think I've worked out one way of doing it though. The AJAX request returns the URL to an external JS file (if necessary) which the code already on the page uses to create a new script element, append it to the <head> element and then call the function within. Not perfect, but it seems to be working well enough for my purposes
|
|
ME!
Moderator
~Remanifesting-Eternal.~
Posts: 778
|
AJAX
Feb 26, 2007 16:04:28 GMT
Post by ME! on Feb 26, 2007 16:04:28 GMT
So Ross, what you want to do is when request is sent you want to write specific JS on to the web page? why not setup a function that when a form submit button is pressed it writes a specific JS file using a function. If you want those text/links to be more persistent, why not use cookies? and it reads the cookie and writes that JS file. I'm not 100% sure what you want done, maybe a little more detail ? >.< More detail would probably give away too much I think I've worked out one way of doing it though. The AJAX request returns the URL to an external JS file (if necessary) which the code already on the page uses to create a new script element, append it to the <head> element and then call the function within. Not perfect, but it seems to be working well enough for my purposes you and your top secret projects lol the method sounds good
|
|
|
AJAX
Feb 27, 2007 0:38:59 GMT
Post by FireIndy on Feb 27, 2007 0:38:59 GMT
So Ross, what you want to do is when request is sent you want to write specific JS on to the web page? why not setup a function that when a form submit button is pressed it writes a specific JS file using a function. If you want those text/links to be more persistent, why not use cookies? and it reads the cookie and writes that JS file. I'm not 100% sure what you want done, maybe a little more detail ? >.< More detail would probably give away too much I think I've worked out one way of doing it though. The AJAX request returns the URL to an external JS file (if necessary) which the code already on the page uses to create a new script element, append it to the <head> element and then call the function within. Not perfect, but it seems to be working well enough for my purposes Well Ross, I have no idea what you are talking about, but I guess maybe later in my life Ill look at some AJAX. Wouldnt AJAX be somewhat similar to PHP because it deals with servers(etc)?
|
|
ME!
Moderator
~Remanifesting-Eternal.~
Posts: 778
|
AJAX
Feb 27, 2007 1:07:01 GMT
Post by ME! on Feb 27, 2007 1:07:01 GMT
More detail would probably give away too much I think I've worked out one way of doing it though. The AJAX request returns the URL to an external JS file (if necessary) which the code already on the page uses to create a new script element, append it to the <head> element and then call the function within. Not perfect, but it seems to be working well enough for my purposes Well Ross, I have no idea what you are talking about, but I guess maybe later in my life Ill look at some AJAX. Wouldnt AJAX be somewhat similar to PHP because it deals with servers(etc)? actually its more like Javascript, just with functions that are specifically used/considered as AJAX
|
|