Current location: Hot Scripts Forums » Programming Languages » PHP » How to run ajax...


How to run ajax...

Reply
  #1 (permalink)  
Old 11-24-09, 06:15 AM
rsmahaa rsmahaa is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
How to run ajax...

Hi all,

I have downloaded one script from W3schools for page loading. Its not running in localhost like php.
Is any s/w required for Ajax specially or any configuration req?
any one help me......
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-24-09, 06:25 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Please post your code; without that it's very difficult to guess what's going on.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-24-09, 08:34 AM
rsmahaa rsmahaa is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for reply. my code is here......

HTML Code:
<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    document.getElementById('T1').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}
</script>
</head>

<body onload="loadXMLDoc('test_xmlhttp.txt')">
<div id="T1" style="border:1px solid black;width:300;padding:5"></div><br />
<button onclick="loadXMLDoc('test_xmlhttp2.txt')">Click</button>
</body>

</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-24-09, 08:59 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
I don't see anything wrong with your code.

Make sure you have the two files "test_xmlhttp.txt and test_xmlhttp2.txt" in the same directory as your main file.
If they aren't in the same directory, then make sure the path to those files are correct in the code.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 11-24-09, 07:34 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
Quote:
Originally Posted by rsmahaa View Post
Hi all,

I have downloaded one script from W3schools for page loading. Its not running in localhost like php.
Is any s/w required for Ajax specially or any configuration req?
any one help me......
Are you saying that test_xmlhttp.txt isn't retrieved?
OR,
The file isn't parsed by PHP?


If it is number 2, change the extension from .txt to .php .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 11-25-09, 11:39 PM
rsmahaa rsmahaa is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
The file isn't parsed by PHP?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 11-26-09, 08:20 AM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
Quote:
Originally Posted by rsmahaa View Post
The file isn't parsed by PHP?
When the file is retrieved, you get the PHP code, and not the desired output.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 11-29-09, 08:19 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Check out XAMPP. apache friends - xampp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] AJAX: collapsible panel mariowowo JavaScript 4 06-25-08 08:59 AM
[SOLVED] AJAX Cache DAL JavaScript 7 06-17-08 10:15 AM
ajax or css i dont know mjr JavaScript 2 03-02-07 12:37 PM
AJAX problem with php dynamic url scott2500uk PHP 3 10-28-06 11:33 AM
need Java script ( Ajax) Calendar, tree, grid curtisannev Job Offers & Assistance 1 10-30-05 09:59 PM


All times are GMT -5. The time now is 11:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.