![](/img/trans.png)
[英]WordPress: Loading another page/post inside the "the_content" filter creates an 500 Internal Server Error
[英]Loading Server Content on Another Window
我有一个onclick事件,旨在启动一个javascript函数getDeadlineInfo
function getDeadlineInfo(string) //string holds name of deadline
{
document.location.href='deadlineInfo.htm';
}
它的意思是打开一个新页面“ deadlineInfo.htm”。 我需要一个新页面来显示服务器上的内容,而我有自己的功能:
function contactServer(str)
{
...additional code here
xmlhttp.open("GET","serverScript.php?q="+str,true);
xmlhttp.send();
}
问题是我不知道如何将传递到getDeadlineInfo的字符串变量发送到用于查找sql数据库的str 。 我一直在搜寻,大多数方法都包括使用类似http://www.tek-tips.com/faqs.cfm?fid=5442的方法 ,如果我附加了格式如document.location.href="deadlineInfo.htm?name="+string;
谢谢你的帮助!
如果您想在整页刷新之间传递信息,则可以通过服务器(通过提交值并将其再次放置在响应html中(例如var str =“”)来完成,也可以使用某种客户端存储,例如Cookie。
几个建议。
encodeURIComponent
> document.location.href="deadlineInfo.htm?name="+encodeURIComponent(string);
编码url参数document.location.href="deadlineInfo.htm?name="+encodeURIComponent(string);
$_GET
集合在服务器上处理name
参数 name
函数 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.