Page 1 of 1

please solve this small problem

Posted: Tue Feb 20, 2007 7:43 am
by anciwasim
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]

Posted: Tue Feb 20, 2007 8:19 am
by feyd
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
It would help to have a description of the problem you are having, what is happening and what you are expecting.

What have you done to find the bug?

is it possible to create grid.in php with connected

Posted: Thu Feb 22, 2007 11:37 am
by anciwasim
is possible to create a grid control in java script and that will be direct connect with mysql using php,and control also allow to direct editing facility.

Posted: Thu Feb 22, 2007 1:33 pm
by volka
javascript runs client-side, php server-side.
You might be looking for http://en.wikipedia.org/wiki/Ajax_%28programming%29