// Check for Ajax Request
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
//Do stuff here
}
// Check for Ajax Request
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
//Do stuff here
}
var answer = DivId;
$.ajax({
type: 'GET',
url: 'path_to_file/gscript2.php',
data: 'answer=' + answer,
success: function(response) {
$('#ajax_content').html(response);
}
});
<?php
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
) {
// AJAX request
$answer = $_GET['answer'];
$div_id=$answer;
echo "div id is: " . $div_id . "<br/>";
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
$result_g1 = mysql_query("SELECT * FROM teams WHERE div_id=$div_id");
while($row = mysql_fetch_array($result_g1, MYSQL_BOTH))
{
$team_id=$row[team_id];
$team_name=$row[team_name];
echo $team_id . " " . $team_name . "<br/>";
}
}
?>
cache: false as such:$.ajax({
cache: false,
type: 'GET',
...
It works by appending "_={timestamp}" to the GET parameters.
1 2 3 4
$text = "freeze coders";
$text1 = ucwords($text); // Output - Freeze Coders
1 2 3 4
$text = "freeze coders";
$text1 = strtoupper($text); // Output - FREEZE CODERS
1 2 3 4
$text = " FREEZE CODERS";
$text1 = strtolower($text); // Output - freeze coders
1 2 3 4
$text = "freeze coders";
$text1 = ucfirst($text); // Output - Freeze coders
1 2 3 4
$text = " FREEZE CODERS";
$text1 = lcfirst($text); // Output - fREEZE CODERS
<?php # @function upload_file # # @param $field string the name of the file upload form field # @param $dirPath string the relative path to which to store the file (no trailing slash) # @param $maxSize int the maximum size of the file (in bytes) # @param $allowed array an array containing all the"allowed"file mime-types # # @return mixed the files' stored path on success, false on failure.function upload_file($field ='', $dirPath ='', $maxSize = 100000, $allowed = array()) { foreach ($_FILES[$field] as $key => $val) $$key = $val; if ((!is_uploaded_file($tmp_name)) || ($error != 0) || ($size == 0) || ($size > $maxSize)) return false; // file failed basic validation checks if ((is_array($allowed)) && (!empty($allowed))) if (!in_array($type, $allowed)) return false; // file is not an allowed type do $path = $dirPath . DIRECTORY_SEPARATOR . rand(1, 9999) . strtolower(basename($name)); while (file_exists($path)); if (move_uploaded_file($tmp_name, $path)) return $path; return false; } // DEMO /* if (array_key_exists('submit', $_POST)) { if ($filepath = upload_file('music_upload','music_files', 700000, array('audio/mpeg','audio/wav'))) echo'File uploaded to '. $filepath; else echo"An error occurred uploading the file... please try again."; } echo'<form method="post"action="enctype=' .$_SERVER['PHP_SELF']. '""multipart/form-data"> <input type="file"name="music_upload"id="music_upload"/> <input type="submit"name="submit"value="submit"/> </form>';print_r($_FILES); // for debug purposes */ ?>
Refer to the commented section of code under the function labeled DEMO for usage.
Hello Friends! I am Ramana a part time blogger from Hyderabad.