Jump to content

barkermn01

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

barkermn01's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Mate Check that your using innerHTML and there is no line break being past if that dose not work paste your code in here
  2. Sorry in the xhr.responseText Should be xmlHttp.responseText
  3. Dont, Dont even then about posting it FF3 may be the most downloaded file on the internet(recoreded) But is its Cr*p its CSS interpriter is Patatic and its Javascript is worse if you have problems wiht a site running on FF3 and it runs fine of FF2 LEAVE it dont mess with it hopefully Mozila will fix that mess of a program so it works like FF2 did and loads sites properly
  4. Then it is not an AJAX Problem as abort() stop the connection thus stops the php if you are constanly reloading via AJAX try using a IFrame and add an out refresh to the code it would use so mutch less processing power allso the more javascript you use slower your site becomes
  5. Easy function GetXmlHttpObject(){ var xmlHttp=null; try{ xmlHttp=new XMLHttpRequest(); } catch (e){ //Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function getPage(url){ xmlHttp=GetXmlHttpObject(); if (xmlHttp==null){ alert ("Browser does not support HTTP Request"); return; } url=url+"?sid="+Math.random(); // fix to keep IE from cacheing the page xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState == 4){ document.getElementById("").value = xmlHttp.responseText; // The ID of your Text box }else{ // Your Code to do when you dont have your page loaded so a nice laoding image works } } xmlHttp.send(null); } Then onClick of your button getPage('random.php');
  6. <body onUnload="AJAXHandle.abort();" /> This will stop your AJAX Call if the refresh or leave the page so php is terminated
  7. Forget the Name AJAX(asynchronous Javascript and XML) This is old and what it was made for but the power is so mutch more The Best way to call AJAX function GetXmlHttpObject(){ var xmlHttp=null; try{ xmlHttp=new XMLHttpRequest(); } catch (e){ //Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } This Check for the calls to return if the dont or return false then they fail xmlHttp=new XMLHttpRequest(); is for All None IE Browsers that support AJAX xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); is for IE 5 and 6 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); is for IE7 onwards So we now have a check for witch browser they are using and the way to call AJAX but we need to call it function getPage(url){ xmlHttp=GetXmlHttpObject(); if (xmlHttp==null){ alert ("Browser does not support HTTP Request"); return; } url=url+"?sid="+Math.random(); // fix to keep IE from cacheing the page xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState == 4){ // Your Code to do when you have the result }else{ // Your Code to do when you dont have your page loaded so a nice laoding image works } } xmlHttp.send(null); } This function will load what ever page you want and will not cash it That is the basics of AJAX and compient for all browsers, But back to my title we dont want to use AJAX for XML well unless using it for an RSS fead So what dose AJAX Return? Well AJAX has the power to return any text vaule so a web page source loads and you just get javascript to right it to the page so there is one thing what about you want changeing values to be returned, say some dates dates.html 01/01/2001;02/02/2001;03/03/2001;04/04/2001;05/05/2001;06/06/2001;07/07/2001;08/08/2001; So what can AJAX do with that Well this is a demo function GetXmlHttpObject(){ var xmlHttp=null; try{ xmlHttp=new XMLHttpRequest(); } catch (e){ //Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function getPage(url){ xmlHttp=GetXmlHttpObject(); if (xmlHttp==null){ alert ("Browser does not support HTTP Request"); return; } url=url+"?sid="+Math.random(); // fix to keep IE from cacheing the page xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState == 4){ getPage('dates'); var data = xhr.responseText.split(/\s?\;\s{0,3}/g); var amount1 = data.count(); var i; while(i != amount1) { document.write(data[i]+'<br />'); } }else{ // Your Code to do when you dont have your page loaded so a nice laoding image works } } xmlHttp.send(null); } This will then list the dates but this like i said RSS Feeds can stay upto date with the use of AJAX But that is uses XML Just be creative with AJAX and it can work for you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.