اینم کد:
page:"ajax.js"
var http=getHttp();
var code=0;
//***********************
function getHttp()
{
var xmlhttp;
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
// Internet Explorer
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
if(typeof XMLHttpRequest !='undefiend')
{
xmlhttp=new XMLHttpRequest();
}
}
}
return xmlhttp;
}
//*******************************
function sendtorecieveforadd(){
title=document.getElementById("tftitle").value;
agency=document.getElementById("tfagency").value;
items=title+","+agency;
http.open("GET","new.php?params="+items,false);
http.onreadystatechange=answerofadd;
http.send(null);
}
//************************
function answerofadd()
{
if(http.readystate==4)
{
r=http.responseText;
newsid=r;
if(r!="-1")
Add(newsid,title,agency);
}
}
//******page index********
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
<style type="text/css">
.style1 {
text-align: center;
}
</style>
<script type="text/javascript" src="ajax.js" defer="defer"></script>
</head>
<body >
Title:<input name="tftitle" type="text" />
<p>Agency:<input name="tfagency" type="text" />
<input name="Button1" type="submit" value="Add" onclick="sendtorecieveforadd();"/>
</body>
</html>