Not directly related to wwb

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Not directly related to wwb

Post by alex4orly »

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
User avatar
BaconFries
 
 
Posts: 5364
Joined: Thu Aug 16, 2007 7:32 pm

Re: Not directly related to wwb

Post by BaconFries »

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.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Not directly related to wwb

Post by alex4orly »

Yes, I tried that, but it still ends up with the PHP blank page, not the current page it was called from

Thanks again
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Not directly related to wwb

Post by alex4orly »

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
function 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 following is the final part of the PHP script itself
// 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);
}
The next function call is showTopic(htmlPage), for each button, the parameter is different, here is that function script
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
}
Is there any problem with this seup?
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
Post Reply