我正面临一个问题,我无法理解我的生活。我有一个主欢迎页面,其中所有内容都通过javascript / ajax脚本加载 我在Dynamic Drive找到了。但是,我遇到的问题是,我用PHP或HTML编写的任何表单都不会将输入字段返回给PHP脚本。我花了好几天试图找到一个简单的解决方案,没有运气,所以在这一点上,我只是期待这个伟大的编码社区的想法或帮助。这是用于加载的ajax / javascript的链接:
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
此外,任何其他链接都可以很好地加载并快速加载。我只是在添加表单方面遇到问题,我希望用户在他们的个人资料中添加图片以及我网站上的那类内容。提前感谢任何花时间阅读并提供帮助的人,克莱顿。
这是javascript / ajax脚本,它在我的welcome.php
页面上加载容器div内的所有内容。下面是我在settings.php
页面上设置的表单代码。
<script type="text/javascript">
/***********************************************
* Dynamic Ajax Content- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Please keep this notice intact
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var bustcachevar=1//bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""
function ajaxpage(url, containerid) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange = function() {
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
</script>
&#13;
<form name="settings" id="settings" action="javascript:ajaxpage('../addons/settings.php?action=update', 'container');" method="get">
<input type="text" name="image" id="image" placeholder="picture url"/>
<input type="text" name="mname" id="mname"/>
<input type="submit"/>
</form>
&#13;