Archive for the ‘PHP’ Category

How to eliminate cached data error from AJAX

Since AJAX load method uses jQuery get method internally, So that you may get cached data.

To remove this this error make sure to send a unique key as part of the query string and it will give you the new content /result /uncached data from server.

A simple ajax function

function unassign_shop(full_id)

{
var n=full_id.length;
var id=full_id.substr(9,n-9);
var commentContainer = $("div#unassigned_" + id).parent();
var str = 'remove_shop=removed&salesman_id=' + <?php echo $salesman_id; ?> + '&assign_id=' + id ;
commentContainer.slideUp('slow', function() {$("div#assigned_" + id).remove();});
 
document.getElementById("unassigned").innerHTML="<img src='../design/content/loading.gif' title='loading' />";
 
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=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("unassigned").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax/fetch_unassigned.php?"+str,true);
xmlhttp.send();
}

If you use some functions like above  then you will get only the cached data because the query string is same as in most cases.

var str = 'remove_shop=removed&salesman_id=' + <?php echo $salesman_id; ?> + '&assign_id=' + id ;

One solution is to pass timestamp value as part of the query string so that it will generate a unique request.

Read more »

View, delete and download mediafire folder contents from our website

Mediafire controls are used for extending storage capacity of any website, we can buy one mediafire account and include all mediafire controls in our website so that the data storage problem can be easily rectified.

To include mediafire controls in our website, we should know about mediafire REST API —> Please read the Mediafire REST API Documentation from mediafire website or Click Here

Once you are familiar in Mediafire REST API then you can perform all the actions that can be done by using mediafire are also done from your own website.

For Adding this control into your website do the following steps

Step 1

Create an account in mediafire —> https://www.mediafire.com

Step 2

Go to My Account and click Developers link

or

goto —> https://www.mediafire.com/myaccount/applications.php

 

Read more »

Find the distance between two geographic area using latitude and longitude values in php

To download source code click the link below

Download source code – Click Here

To find the distance between two geographic area we need to get both latitude and longitude values of that location.

To find lattitude and longitude of a location please read my blog post —> Display Latitude and Longitude value of a location from google map

Please enter both latitude and longitude value in the textbox and click Find Distance button.

To download source code click the link below

Download source code – Click Here


Read more »