Top

Comments

  (99)  RSS
vaseline28's
F*U*R*B*Y*
Comments: 585
 
Javascript Snippet:  AJAX ParaGraph Toggle
Posted on Oct 7, 2008 10:05 pm
still waiting for the preview that says, will do one tomorrow ;) hehehe :)

although, i do like the look of the script, especially how you select which page you want.... i never thought of doing it like this, how i've always done it is, created another php page, that, when called upon, gets $_GET['page'] and then gets the contents of $_GET['page'] and displays that :)

Either way, yours is a good script, :) Good job
Hawkee
Comments: 566
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 30, 2008 3:46 pm
Looking better vaseline, but there is still some room for improvement. Your ajaxXML_Request() function should take URL_ofPage as an input so a dynamic document URL can be called. It would also be helpful to see the HTML code to call this. And finally, your spacing is a bit off with the brackets not lining up properly.
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 30, 2008 2:15 pm
Updated a bit to be more similar to what Hawkee recommended.
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 21, 2008 1:35 pm
Mmmm, I've got round the problem by doing:
Code:
echo "<body onload=" . $qt . "ajaxGenerate_Content('ajaxContent_generate','/Site/ajaxCon/" . $_GET['value'] . ".php?mthd=AJAX')" . $qt . ">";

Obviously with a case for if $_GET['value'] is not a recognised file, that way someone can link to a specific page with:
http://www.vasey.co.cc/Site/?value=Scripting
Hawkee
Comments: 566
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 7:58 pm
I'm just saying that if you'd like people to bookmark a page, or if you'd like the search engines to spider the page, you just can't link to it with AJAX.
jonesy44
Comments: 1,085
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 6:04 pm
yeah, but people are too picky..
If you were gonna link someone to a site like omega, you'd know the page linking system. else, there's no need. simple logic.

Anyways, there's not much to it..
Hawkee
Comments: 566
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 3:58 pm
Yeah you need to be careful with AJAX because you need to maintain a proper URL to page ratio. If you make each of your pages an AJAX call then you won't have separate URLs. It's better to use AJAX only when it doesn't adversely affect the URLs.
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 12:48 pm
That's very true, another way to do it would be to add in a Javascript script to pages like this:
http://omega.neeq.net/home.php
So if the URL is that it will redirect them to:
http://omega.neeq.net/?page=/home.php

It's also a pain to make it work for Search Engine crawls...
jonesy44
Comments: 1,085
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 12:38 pm
lol, thanks!

Such as; you can't link people to it. it's still http://omega.neeq.net even if you're on downloads page. now to me, that's no biggy cos if you're linking out as the admin, i've made a function;

?page=/pagename

But hey! retarded critics, who don't know the full power of it STILL want to bitch about everything.
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 12:17 pm
Yeah, I'd noticed that. Of course there are drawbacks, which particular ones did you encounter?

And site looks great btw. I remember when Lindrian pointed me to it...'Wow! That's awesome'
jonesy44
Comments: 1,085
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 11:56 am
Neat! Nice work bud. I used a lot of ajax on lindrian's site. although i now realise it does have some drawbacks;

http://omega.neeq.net
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 10:40 am
Thanks jonesy :)
I'm starting to get the hang of it, so if you do need help, feel free to let me know...'course there are no guarantees that I can ACTUALLY help you!

Edit: I've added in:
Code:
  if(xmlHttp.readyState!=4)
    {
      // Commands in this section of the script will be triggered when the content is being fetched, but has not come through yet.
     // For example, you might want to put in:
     // document.getElementById('example').innerHTML="**Content loading...please wait**";
    }


This script is taken from my webpage which is currently in development - you can see the extent of even very basic AJAX here: http://www.vasey.co.cc/Site/
jonesy44
Comments: 1,085
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 6:06 am
I'm crap with ajax tbh. only made one site with it, and had to use tutorials and examples almost throughout, helpful with the comment lines. :]

7/10
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 14, 2008 3:38 am
I see, OK, I'll modify this when I get back - have to go out now.
Hawkee
Comments: 566
 
Javascript Snippet:  AJAX XMLHttp Request Aid
Posted on Sep 13, 2008 4:54 pm
You don't really need to get xmlHttp every time an AJAX call is made. That can be done outside the function upon page load. I also think you should have done onreadystatechange to a function that handles the response, like this:

Code:
...
element = 'mydiv';
xmlHttp.onreadystatechange = handleResponse;
xmlHttp.send(null);

function handleResponse()
{
    if(xmlHttp.readyState == 4)
    {
        var response = xmlHttp.responseText;
        document.getElementById(element).innerHTML = response;
    }
}


This example will only work if xmlHttp and 'element' are declared globally.
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX ParaGraph Toggle
Posted on Sep 10, 2008 10:15 am
I agree, document.write() really doesn't suit AJAX in the slightest. I tried assigning a variable and then adding the variable, but it didn't work.

It really beats me as to why it was not working...
Hawkee
Comments: 566
 
Javascript Snippet:  AJAX ParaGraph Toggle
Posted on Sep 9, 2008 3:00 pm
Could try this, but what you have should work in IE. I don't really recommend using document.write as that's not really AJAX.
Code:
var response = xmlHttp.responseText;
document.getElementById(a).innerHTML = response;
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX ParaGraph Toggle
Posted on Sep 9, 2008 2:50 pm
I've worked out the problem :-)
IE does not like this line:
Code:
document.getElementById(a).innerHTML=xmlHttp.responseText;

if that is changed to:
Code:
document.write(xmlHttp.responseText);

IE is fine, but the rest of the toggling does not work. Can you see the problem with the line? The error message is "Unknown runtime Error".
Hawkee
Comments: 566
 
Javascript Snippet:  AJAX ParaGraph Toggle
Posted on Sep 9, 2008 2:43 pm
I don't see how the webhost could have anything to do with IE running Javascript.
vaseline28
Comments: 154
 
Javascript Snippet:  AJAX ParaGraph Toggle
Posted on Sep 9, 2008 1:06 pm
Oh, this example only works for browsers other than IE, the webhost does not support IE
1 2 3 4 5 Next
Bottom