I just need some help....
I have a "pages.html", in it, a JavaScript function.
At the end of that function, I am calling an external "page.php" to update a record on the server.
I am using window.location.href to do the job.
The problem is, this action is moving the visitor from the current page onto the page.php, which has no UI at all.
Is there a way, to do that function, but stay with the calling page?
The best would be to have the PHP script as part of the calling page, but PHP script is server side...
Any suggestions?
Cheers
Not directly related to wwb
- BaconFries
-
- Posts: 5640
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Not directly related to wwb
Have you considered using window.open(url, "_self") over window.location.href = "url"; were "url" is the page.php. Note using this it will stay on the same page but open in a "New" window.
Re: Not directly related to wwb
Yes, I tried that, but it still ends up with the PHP blank page, not the current page it was called from
Thanks again
Thanks again
Re: Not directly related to wwb
Well, here are some details of my setup
1) I have a button, which upon clicking it - it reveals a hidden Modal hidden dialogue
2) In the Events action - I have TWO calls, to two javascript functions:
The first one - WritePageVisit(), is a call to a php script on the server, here are the scripts
The calling function has in it the following script
Should I have some sort of delay between the calls, to allow the first call to complete the writing to the file?
If so, how?
I am asking this because - if i Don't have the alert() - the php script doesn't execute and the 2nd function brings up the page
Thanks
1) I have a button, which upon clicking it - it reveals a hidden Modal hidden dialogue
2) In the Events action - I have TWO calls, to two javascript functions:
The first one - WritePageVisit(), is a call to a php script on the server, here are the scripts
The calling function has in it the following script
The following is the final part of the PHP script itselffunction WritePageVisit()
{
var MyVariable = getCookie('beleura21');
alert(MyVariable); - this pops up - indicating the script is called
var VariablePlaceholder = "myvilla=";
var MyPage = "&mypage=";
var PageName = location.href.split("/").slice(-1);
var PageToSendTo = "https://ourvilla.net.au/pagevisited.php?" + VariablePlaceholder + MyVariable + MyPage + PageName;
window.open(PageToSendTo, 'InlineFrame1');//"_self")
//window.location.href = PageToSendTo;
return false;
}
The next function call is showTopic(htmlPage), for each button, the parameter is different, here is that function script// Write record for visitors only
if (is_numeric($varVilla) )
{
// Now, format the output log record to be written to the file
$output = $today . "," . $varVilla . "," . $varUserName . "," . $user_ip . "," . $Device . "," . $City . "," . $Country . $logdata;
$file = fopen("villalog.csv","a");
fwrite($file,$output);
fclose($file);
}
Is there any problem with this seup?function showTopic(htmlPage)
{
pageName = htmlPage; // The argument here is passed from the onclick of the button calling it
var url = 'https://ourvilla.net.au/';
var goto = url.concat(pageName);
window.open(goto , 'InlineFrame1'); // Show the HTML page inside the iFrame
$('#Dialog1').dialog('open'); // The Dialog is initially hidden on page load
}
Should I have some sort of delay between the calls, to allow the first call to complete the writing to the file?
If so, how?
I am asking this because - if i Don't have the alert() - the php script doesn't execute and the 2nd function brings up the page
Thanks