为什么不工作?! [英] why not working?!
问题描述
您好,
以下代码旨在将日期格式为yyyyMMdd格式
从html文件中的javascript日历传递到php in另一个
文件,然后搜索MySQL数据库。
由于某种原因,sendPhp无效。
我需要发送
target = frameright(因为next.php搜索的结果出现在
右侧框架中),并且
submit = 1
有什么想法吗?!
干杯
Geoff
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN">
< ; html>
< head>
< title> Sounds< / title>
< link rel =" STYLESHEET" type =" text / css"
href =" ../ assets / style / sounds.css">
< script type = "文本/ JavaScript的" src =" fcp_calendar.js">< / script>
< script type =" text / javascript">
窗口。 onload = function(){
cal = new _
fcp.Calendar(document.getElementById(" cal_placehol der));
cal.onselect = function(date){;
function dateToISO(date){
var year = date.getFullYear();
var month = date.getMonth()+ 1;
var day = date.getDate();
if(month< 10)month =" 0" +月;
if(day< 10)day =" 0" +天;
返回年份+月份+日期;
};
newdate = dateToISO(日期) ;
//下面的2个函数用于将javascript变量
//传递给php文件,next.php
函数xmlreq(){
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if(window.ActiveXObject){
req = new ActiveXObject(" Microsoft.XMLHTTP");
}
返回(req);
};
函数sendPhp(url){
var req = xmlreq( );
req.onreadystatechange = stateHandler;
req.open(" GET",url,true);
sreq.send(null);
};
sendPhp(" next-right.php?searchfield = date& term = newdate& target = fra meright''& ; submit = 1");
}
}
< / script>
Hello,
The code below is aimed at passing the date in the yyyyMMdd format
from the javascript calendar in an html file to the php in a another
file which then searches a MySQL database.
For some reason the sendPhp is not working.
I need to send
target=frameright (as the results of the next.php search appear in the
right hand frame), and
submit=1
Any ideas please?!
Cheers
Geoff
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Sounds</title>
<link rel="STYLESHEET" type="text/css"
href="../assets/style/sounds.css">
<script type="text/javascript" src="fcp_calendar.js"></script>
<script type="text/javascript">
window.onload = function() {
cal = new _
fcp.Calendar(document.getElementById("cal_placehol der"));
cal.onselect = function(date) {;
function dateToISO(date) {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
return year + month + day;
};
newdate = dateToISO(date);
// the 2 functions below are used to pass the javascript variable
//to the php file, next.php
function xmlreq(){
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
}else if(window.ActiveXObject){
req = new ActiveXObject("Microsoft.XMLHTTP");
}
return(req);
};
function sendPhp(url){
var req = xmlreq();
req.onreadystatechange = stateHandler;
req.open("GET", url, true);
sreq.send(null);
};
sendPhp("next-right.php?searchfield=date&term=newdate&target=fra meright''&submit=1");
}
}
</script>
推荐答案
O. 3月3日,15:01,Geoff Cox写道:
On 7 Mar, 15:01, Geoff Cox wrote:
>
由于某种原因,sendPhp无效。
>
For some reason the sendPhp is not working.
尝试调用sendPhp时会发生什么?你有没有得到特别的
错误信息。
过去使用相对网址时遇到问题
XMLHttpRequest .open(),所以我现在经常使用完全合格的网址作为
它似乎可以避免很多问题。
hth。
wp。
What happens when you try to call sendPhp? Do you get a particular
error message.
I have encountered problems in the past when using a relative url with
XMLHttpRequest.open(), so I routinely use fully qualified urls now as
it seems to avoid a lot of problems.
hth.
wp.
2007年3月7日07:12:26 -0800,wisestpotato
< wi ********** @ googlemail.comwrote:
On 7 Mar 2007 07:12:26 -0800, "wisestpotato"
<wi**********@googlemail.comwrote:
> 3月7日15:01,Geoff Cox写道:
>On 7 Mar, 15:01, Geoff Cox wrote:
>>
由于某种原因,sendPhp无效。
>>
For some reason the sendPhp is not working.
当你尝试时会发生什么打电话给sendPhp?您是否收到特定的错误消息?
What happens when you try to call sendPhp? Do you get a particular
error message.
没有出现错误消息!
No error message appears!
>我在使用亲戚时遇到过问题带有
XMLHttpRequest.open()的url,所以我现在经常使用完全合格的URL作为
它似乎避免了很多问题。
>I have encountered problems in the past when using a relative url with
XMLHttpRequest.open(), so I routinely use fully qualified urls now as
it seems to avoid a lot of problems.
完全限定你的意思是sendPhp("< a href = \" next.php等?
干杯
Geoff
by full qualified you mean sendPhp("<a href=\"next.php etc?
Cheers
Geoff
>
hth。
wp。
>
hth.
wp.
3月7日15:47,Geoff Cox写道:
On 7 Mar, 15:47, Geoff Cox wrote:
>
完全限定你的意思是sendPhp("< a href = \" next.php等?
>
by full qualified you mean sendPhp("<a href=\"next.php etc?
对不起,我的意思是你应该尝试在
url中包含完整的路径。即使用www.google.co.uk/somedir/somepage.htm"而不仅仅是
somepage.htm"。
wp。
Sorry, I meant that your should try including the full path within the
url. I.e. use "www.google.co.uk/somedir/somepage.htm" rather than just
"somepage.htm".
wp.
这篇关于为什么不工作?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!