473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

why not working?!

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>
Mar 7 '07 #1
11 1550
On 7 Mar, 15:01, Geoff Cox wrote:
>
For some reason the sendPhp is not working.
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.

Mar 7 '07 #2
On 7 Mar 2007 07:12:26 -0800, "wisestpotato"
<wi**********@googlemail.comwrote:
>On 7 Mar, 15:01, Geoff Cox wrote:
>>
For some reason the sendPhp is not working.

What happens when you try to call sendPhp? Do you get a particular
error message.
No error message appears!
>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.
by full qualified you mean sendPhp("<a href=\"next.php etc?

Cheers

Geoff
>
hth.

wp.
Mar 7 '07 #3
On 7 Mar, 15:47, Geoff Cox wrote:
>
by full qualified you mean sendPhp("<a href=\"next.php etc?
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.

Mar 7 '07 #4
On 7 Mar 2007 08:05:32 -0800, "wisestpotato"
<wi**********@googlemail.comwrote:
>On 7 Mar, 15:47, Geoff Cox wrote:
>>
by full qualified you mean sendPhp("<a href=\"next.php etc?

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.
OK will try that.

Thanks

Geoff
Mar 7 '07 #5
On 7 Mar 2007 08:05:32 -0800, "wisestpotato"
<wi**********@googlemail.comwrote:
>On 7 Mar, 15:47, Geoff Cox wrote:
>>
by full qualified you mean sendPhp("<a href=\"next.php etc?

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.

I am trying this on my own PC so is this correct?

sendPhp("http://127.0.0.1/sounds-great/members/sounds-great-right.php?term=newdate");

Above doesn't work though!

Cheers

Geoff

Mar 7 '07 #6
VK
On Mar 7, 6:01 pm, Geoff Cox wrote:
req.open("GET", url, true);
sreq.send(null);
so "req" or "sreq" ? ;-)
Mar 7 '07 #7
On 7 Mar 2007 10:32:07 -0800, "VK" <sc**********@yahoo.comwrote:
>On Mar 7, 6:01 pm, Geoff Cox wrote:
> req.open("GET", url, true);
sreq.send(null);

so "req" or "sreq" ? ;-)

I know - another typo! Should be req.

Cheers

Geoff
Mar 7 '07 #8
Please name the topic with an appropiate title. "Why not working" is
really a bad idea.
Thanks.

Mar 8 '07 #9
On 7 Mar, 16:49, Geoff Cox wrote:
>
Above doesn't work though!
Ah, in that case, I'd suggest running a packet analyser such as
Ethereal to examine the network traffic between the client and the
server when xmlhttprequest.open() is executed. See if there is
anything anomalous. I'm assuming here that the web browser is on a
different pc to the server.

Failing that, insert some alert() statements into the sendPHP function
to try and gauge where it is falling over.

You could also try changing the xmlhttprequest to use a synchronous
request and see what is returned:

function sendPhp(url){
var req = xmlreq();

req.onreadystatechange = stateHandler;
req.open("GET", url, false);
req.send(null);

alert(req.status); // show the http status code of the
xmlhttprequest, should be 200
};

Mar 8 '07 #10
On 8 Mar 2007 01:42:39 -0800, "wisestpotato"
<wi**********@googlemail.comwrote:
>On 7 Mar, 16:49, Geoff Cox wrote:
>>
Above doesn't work though!

Ah, in that case, I'd suggest running a packet analyser such as
Ethereal to examine the network traffic between the client and the
server when xmlhttprequest.open() is executed. See if there is
anything anomalous. I'm assuming here that the web browser is on a
different pc to the server.

Failing that, insert some alert() statements into the sendPHP function
to try and gauge where it is falling over.

You could also try changing the xmlhttprequest to use a synchronous
request and see what is returned:

function sendPhp(url){
var req = xmlreq();

req.onreadystatechange = stateHandler;
req.open("GET", url, false);
req.send(null);

alert(req.status); // show the http status code of the
xmlhttprequest, should be 200
};
It is indeed 200. In fact I am browsing from the same PC at the local
(127.0.0.1) server as I'm still testing this. Is this OK?

The code used to get the 200 is as follows - you can see that I am
trying to get the date, newdate, from the JavaScipt to the php in
another file with the hope that in this file a search will be made of
the MySQL database and the results appear in the right hand frame.
There are 3 frames - a top one and below that a left and right hand
frame. The file with the code below is in the left hand frame.

I not at all sure whether the url is right?

In the php file I am using the $_POST[] array etc.

Any of this seem wrong?!

Cheers

Geoff
<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 below changes the date to the //yyyy/MM/dd format

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;
return year + month + day;
};

newdate = dateToISO(date);

function xmlreq(){
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
}else if(window.ActiveXObject){
req = new ActiveXObject("Microsoft.XMLHTTP");
};

return(req);

};

function stateHandler()
{
var req = xmlreq();
if (req.readyState == 4)
{
if (req.status == 200)
{
success();
};
else
{
failure();
window.alert("failed");
};
};

return true;
};

function sendPhp(url){
var req = xmlreq();
req.onreadystatechange = stateHandler;
req.open("POST", url, false);
req.send(null);
alert(req.status); // show the http status code of the
//xmlhttprequest, should be 200
};

sendPhp("http://127.0.0.1/sounds/members/sounds-right.php?searchfield=\"date\"&term=newdate&submit =1");

};

};

</script>
Mar 8 '07 #11
On 8 Mar 2007 01:42:39 -0800, "wisestpotato"
<wi**********@googlemail.comwrote:
Finally got it working!!

I have used following approach instead of the AJAX approach.

window.parent.frameright.location.href = _
"http://127.0.0.1/sounds/members/sounds-right.php?searchfield=" + _
value + "&term=" + newdate + "&submit=" + submitvalue;

Cheers

Geoff
Mar 9 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mullin Yu | last post by:
hi, i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working therefore, i want to have a unique sub...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
2
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
4
by: qbproger | last post by:
I'm developing a plugin for some software. The previous version of the software didn't require a start in directory to be set. This allowed me to leave the working directory to the default in the...
3
by: Jason Huang | last post by:
Hi, In our C# Windows Form application, we are using the SQL Server 2000 as the database server. The Database table MyTable has a field RegistrationDate which represents the Date a client comes...
0
by: WORKING IN FAITH | last post by:
three years I LOVE You Monica More options 1 message - Collapse all WORKING IN FAITH View profile More options Nov 13, 11:29 am three years I LOVE You Monica
3
by: lds | last post by:
On our server we have both applications that have been migrated to use v2.0 of the framework as well as apps that have not yet been migrated and still use 1.1. When I tried to deploy my v2.0 app...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.