please solve this small problem
Posted: Tue Feb 20, 2007 7:43 am
feyd | Please use
===========================
2 nd file....index.php
================
===================
3rd file connect.php.
=================
<!--This classes wrriten by shaikh wasim and use to connect database;-->[/syntax]
//==================
then..please solve it
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hello all,
i m trying to implementing a small php application ,which use Ajax for data retriving form the server..but it giving a problem and i not able to find the bug.so can you please...identify the problem ,and wat is the solution for that.
i have 3 files 1 st for ajax code,2 nd for dataconnection code,3rd for display page.
Ajax code.=====AX.JS
[syntax="javascript"]// JavaScript Document
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
alert("wasim");
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
alert(ajaxRequest.responseText);
var res= ajaxRequest.responseText;
document.getElementById('msgbox').innerHTML=res;
// document.form1.
}
}
ajaxRequest.open("GET", "connect.php", true);
ajaxRequest.send(null);
}2 nd file....index.php
================
Code: Select all
<script language="javascript1.5" >
function addOption()
{
var optn = document.createElement("OPTION");
optn.text = "wasim";
optn.value = "wasim";
document.form1.selectid.options.add(optn);
}
</script>
<html>
<head>
<script src="ax.js"></script>
</head>
<body >
<div id="msgbox"> DataComes here</div>
<hr color="#999900" size="100%">
<span id="spanselect">
<form id="form1" name="form1" method="get">
<select id="selectid" name="selectid">
<option id="selectoptid" value="1">1</option>
</select>
<input type="button" value="Click here to add option" onClick="ajaxFunction();">
</form>
</span>
</body>
</html>3rd file connect.php.
=================
<!--This classes wrriten by shaikh wasim and use to connect database;-->[/syntax]
Code: Select all
<?php
class Mysql
{
var $link;
function Mysql($host,$username,$database)
{
print "<h1>Host connected</h1>";
$link=mysql_connect($host,$username) or die(mysql_error());
mysql_select_db($database,$this->$link);
}
function query($sqlquery)
{
$result=mysql_query($sqlquery,$this->$link);
return $result;
}
}
$dbconnect=new Mysql("localhost","root","drkapil");
?>then..please solve it
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]