Google Ads

Proudly Hosted on

About Me

Hi, I 'm Aditya, the guy behind this website and many other. This site acts as my web playground, where I share all about me, my work and my knowledge.

I have over 8 yrs hands on experience in PHP, Mysql, JavaScript, open sources CMS like Joomla, Wordpress etc. During these 8 years, I have worked on more than 200 projects and/or websites but could not spare time for my blog.

 

 

Archive for the ‘Ajax’ Category

My Facebook Chat is a jQuery chat software that uses PHP and mySQL. It is placed at the bottom of your website similar to Facebook Chat.

The script is fully customizable from within the administration panel. Customers of My Facebook Chat are also able to buy or sell modifications, themes, and plugins for the software from our built-in store. The chat script will integrate seamlessly with your existing user database, even on a custom website.

SocialTwist Tell-a-Friend More
Tags: ,   |  Posted under Ajax, jquery & others  |  Comments  Comments Off on Facebook Like chat
Last Updated on Saturday, 15 January 2011 11:17

Autocomplete/ Autosuggest is a feature provided by many web browsers, e-mail programs, search engine interfaces, source code editors, database query tools, word processors, and command line interpreters. Autocomplete involves the program predicting a word or phrase that the user wants to type in without the user actually typing it in completely.

Here i am going to demonstrate a simple example of autosuggest. Thi is based on php and ajax. It will fetch country names based on the keyword entered in textbox from the database. We will create three files for this:-

1. First Step :- Make a HTML file containing the textbox

SocialTwist Tell-a-Friend More
Tags: , , ,   |  Posted under Ajax  |  Comments  Comments Off on Ajax AutoComplete
Last Updated on Sunday, 16 May 2010 09:34

 Shorthand for asynchronous JavaScript and XML, is a group of interrelated web development techniques used on the client-side to create interactive web applications. With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page.

The use of Ajax techniques has led to an increase in interactive or dynamic interfaces on web pages. Data is usually retrieved using the XMLHttpRequest object. Despite the name, the use of JavaScript and XML is not actually required, nor do the requests need to be asynchronous.

AJAX is based on the following web standards:

  • JavaScript
  • XML
  • HTML
  • CSS

AJAX uses the XMLHttpRequest object

To get or send information from/to a database or a file on the server with traditional JavaScript, you will have to make an HTML form, and a user will have to click the "Submit" button to send/get the information, wait for the server to respond, then a new page will load with the results. Because the server returns a new page each time the user submits input, traditional web applications can run slowly and tend to be less user-friendly.

With AJAX, your JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object.

With the XMLHttpRequest object, a web page can make a request to, and get a response from a web server – without reloading the page. The user will stay on the same page, and he or she will not notice that scripts request pages, or send data to a server in the background.

To demonstrate the AJAX PHP connection we will create a very simple form with 2 input fields. In the first field you can type any text and we will send this text to our PHP script which will convert it to uppercase and sends it back to us

HTML code

<body>
	<form name="testForm">

	Input text: <input type="text" onkeyup="doWork();" 
	name="inputText" id="inputText" />

	Output text: <input type="text" name="outputText" 
	id="outputText" />

	</form>

</body>

1. First step

 // Get the HTTP Object 
 function getHTTPObject(){ 
 
	if (window.ActiveXObject) 

 		return new ActiveXObject("Microsoft.XMLHTTP"); 
  	else if (window.XMLHttpRequest) 
 
		return new XMLHttpRequest(); 
 
	else { 
 
		alert("Your browser does not support AJAX."); 
		return null; 
		} 
	}

2. Second Step

// Implement business logic 
 function doWork(){ 
 	 httpObject = getHTTPObject(); 
	 if (httpObject != null) {  
	 	httpObject.open("GET", "upperCase.php?
		inputText="+document.getElementById
		('inputText').value, true); 
		httpObject.send(null); 
		httpObject.onreadystatechange = setOutput; 
		} 
	 }

3. The last step on client side is to implement the setOutput() function which will change the value of our second field.

  • 0 = uninitialized
  • 1 = loading
  • 2 = loaded
  • 3 = interactive
  • 4 = complete
// Change the value of the outputText field 
 function setOutput(){ 
 	 if(httpObject.readyState == 4){ 
	 	document.getElementById('outputText').value 
		= httpObject.responseText; 
		} 
	 } 

 

Implementing the server side functionality is very simple compared to the client side. In the PHP code we just need to check the $_GET super-global array. Afterwards convert it to uppercase and echo the result. So the PHP code is this:

<?php if (isset($_GET['inputText']))
      	echo strtoupper($_GET['inputText']);
      ?>
SocialTwist Tell-a-Friend More
Tags: , ,   |  Posted under Ajax, PHP, Technology  |  Comments  Comments Off on AJAX
Last Updated on Saturday, 15 May 2010 11:54