<?php
$string = '<EM>see</EM> <A href="http://www.epicurious.com/cooking/how_to/food_dictionary/entry?id=1965"><FONT size=-1>CLOUDBERRY</FONT></A>';
$tag = "A";
$regExp = "<" . "$tag" . "[^>]*>";
$string = str_replace("</$tag>", "", $string);
$string = ereg_replace($regExp, "", $string);
echo $string;
?>
Saturday, May 17, 2008
Simple Ajax Script
Ajax.js
subject_id = '';server_script.php
function handleHttpResponse()
{
if (http.readyState == 4)
{
if (subject_id != '')
{
document.getElementById(subject_id).innerHTML =
http.responseText;
}
}
}
function getHTTPObject()
{
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch (E)
{
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
} catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
function getScriptPage(div_id,content_id)
{
subject_id = div_id;
content = document.getElementById(content_id).value;
http.open("GET", "server_script.php?content=" + escape(content), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
index.html
<input onkeyup="getScriptPage('output_div','text_content')"
id="text_content" size="40" type="text>
<div id="output_div">
OutPut will get printed here...!
</div>
<?php
print 'Content Typed - '.$_GET['content'];
?>
Subscribe to:
Posts (Atom)