Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 21st, 2024, 11:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: 'InternetPostData is not a function' error
PostPosted: May 21st, 2017, 2:14 pm 
Offline

Joined: August 22nd, 2005, 11:56 am
Posts: 125
Location: The Netherlands
Opus: Pro 9.75 (Build 16749)
OS: Windows 10 Pro 64-bit
Hello all,

Have the following small Opus script code in my HTML5 web publication, but it doesn't seem to work due to an error!

var url = "http://www.fakeurl.nl/scripts/MapBase.php";
var BaseObj = new Object();
BaseObj.Base_Country = "Country";
BaseObj.Base_Name = "Name";
var Base_Data = InternetPostData(url,BaseObj,true);

Can any one tel me why I get an "InternetPostData is not a function" error!?
Thought InternetPostData was a 'built in' function.

_________________
"World War II Allied Aircraft Crashes in the Netherlands & North Sea" (Made with Opus Pro 9.75), available via https://www.airwar4045.nl


For this message Jan has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 21st, 2017, 11:17 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Jan wrote:
Can any one tell me why I get an "InternetPostData is not a function" error!?

The action is built-in but the corresponding JavaScript function in opus.js is not called InternetPostData which is why any call to that fails.

If the action isn't cutting it, then the beauty of Opus HTML5 is you can use the full power of JavaScript and implement a full blown AJAX handler.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 22nd, 2017, 4:26 pm 
Offline

Joined: August 22nd, 2005, 11:56 am
Posts: 125
Location: The Netherlands
Opus: Pro 9.75 (Build 16749)
OS: Windows 10 Pro 64-bit
Hi Mack,

Thanks for the reply... I've had a look on the Internet for AJAX and JavaScript on how to accomplish all this, but as I am only a "simple hobby programmer", I can't figure out how to make it work. Perhaps you can give me a hint :wink:

What I want to do is the following...
When I click on a button on a page some variables must be sent (via POST) to a .PHP script on my web server and in response I'll have to get back a list of Latitudes and Longitudes which have to be put on a Google Map.
Have tested the script and this works OK!
At first I added a 'Post Web Data' Action to send and retrieve the data, and this works OK, but for just one Latitude and Longitude only... Could not figure out on how to put all the retrieved data into an array, so I therefor used an Opus script with InternetPostData, but as you already indicated that can't work.
OK, AJAX and JavaScript... Perhaps you can help 8)

These are the variables sent to the script:
Base_CountrySelected
Base_LocationSelected
Base_BaseSelected


And these are the variables sent back by the script:
Base_PosLat
Base_PosLon
Base_USAAF
Base_RAF
Base_InUse


They should be put into an array, as there are multiple Base_PosLat, Base_PosLon etc., so it can put it on a Google Map (have the that code already).

Hope you can give me a clue on how to get this all to work :)

Jan

_________________
"World War II Allied Aircraft Crashes in the Netherlands & North Sea" (Made with Opus Pro 9.75), available via https://www.airwar4045.nl


For this message Jan has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 23rd, 2017, 11:46 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
I think then it would be better to stick with the Post Web Action as this sounds more like it's the data that's the issue rather than better control of the process and you may be able to handle data another way.

How are you constructing and echoing the data return in your PHP?

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 24th, 2017, 10:06 pm 
Offline

Joined: August 22nd, 2005, 11:56 am
Posts: 125
Location: The Netherlands
Opus: Pro 9.75 (Build 16749)
OS: Windows 10 Pro 64-bit
Hi Mack,

I know something is wrong, but I can't figure out how to handle the problem; have tried several things but nothing seems to work :(
OK, here is the PHP script that 'echoes' the data..

<?php

// Retrieve data from Opus
$Country = $_POST['Base_CountrySelected'];
$Location = $_POST['Base_LocationSelected'];
$Base = $_POST['Base_BaseSelected'];

// Connect to and retrieve data from the database
$sql = "<Query>";
$stmt = $conn -> prepare($sql);
$stmt -> bind_param('sss', $Country, $Location, $Base);
$stmt -> execute();
$stmt -> bind_result($Base_Lat, $Base_Lon, $USAAF, $RAF, $InUse);

while ($stmt -> fetch())
{
$BaseData .= "&Base_PosLat=" . $Base_Lat . "&Base_PosLon=" . $Base_Lon . "&Base_USAAF=" . $USAAF . "&Base_RAF=" . $RAF . "&Base_InUse=" . $InUse;
}
echo $BaseData;

// Close database connection
$stmt -> close();

?>

Works OK (well, at least all data is retrieved from the database), when I view the script with my web browser, but can't figure out how Opus handles all the echoed data when I use the Post Web Data action.
Problem (for me) is that there must be a way to put the echoed data into an array or something, so that I can read the data from that array and put a marker on a Google Map (already have made the code for this and that works).

Well, I hope you have a "simple" solution; Must be simple as I've probably made some silly mistakes in my code :wink:

Greetings from Holland,
Jan

_________________
"World War II Allied Aircraft Crashes in the Netherlands & North Sea" (Made with Opus Pro 9.75), available via https://www.airwar4045.nl


For this message Jan has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 26th, 2017, 2:30 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Are you expecting your script to return a single row of data or multiple rows joined together?

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 29th, 2017, 9:59 pm 
Offline

Joined: August 22nd, 2005, 11:56 am
Posts: 125
Location: The Netherlands
Opus: Pro 9.75 (Build 16749)
OS: Windows 10 Pro 64-bit
Hi Mack,

Sorry for the 'slight' delay in answering :wink:
When I view the 'result' of the script in my web browser, I get something like this... multiple rows!

&Base_PosLat=52.628365&Base_PosLon=0.930831&Base_USAAF=115&Base_RAF=NA&Base_InUse=1942-1945
&Base_PosLat=52.509057&Base_PosLon=1.411975&Base_USAAF=146&Base_RAF=NA&Base_InUse=1943-1945
etc. etc.

This has to be put into an array (or something else) in Opus so I can use it to read the variables Base_PosLat and Base_PosLon, and plot them on a Google Map....

Jan

_________________
"World War II Allied Aircraft Crashes in the Netherlands & North Sea" (Made with Opus Pro 9.75), available via https://www.airwar4045.nl


For this message Jan has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 30th, 2017, 9:02 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
I think I must be misunderstanding something :?

Can I see this echo in action?

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: May 31st, 2017, 9:15 pm 
Offline

Joined: August 22nd, 2005, 11:56 am
Posts: 125
Location: The Netherlands
Opus: Pro 9.75 (Build 16749)
OS: Windows 10 Pro 64-bit
Hi Mack,

Well, it's always difficult to put the things in writing which are "in my mind", but i'll give it another try :wink:

This is some of the code that I've put in Opus:

On Show

Run the following Javascript:
centerMap = new google.maps.LatLng(53.054763, 4.797715);
optionMap = {
zoom: 6,
center: centerMap,
MapTypeId: google.maps.MapTypeId.TERRAIN,
streetViewControl: false,
scaleControl: false
};
map = new google.maps.Map(document.getElementById('frmMapD'), optionMap);

btnBaseMap
On Left Button Click

Post web data to the URL http://www.texlaweb.nl/airwar4045/scripts/M.php,
use as source the multiple fields: (Base_CountrySelected, Base_CountrySelected) (Base_LocationSelected, Base_LocationSelected) (Base_BaseSelected, Base_BaseSelected),
use as destination the multiple fields: (Base_InUse, Base_InUse) (Base_USAAF, Base_USAAF) (Base_RAF, Base_RAF) (Base_PosLon, Base_PosLon) (Base_PosLat, Base_PosLat)

Run the following JavaScript:
positionMarker = new google.maps.LatLng(_DWPub.Base_PosLat, _DWPub.Base_PosLon);
marker = new google.maps.Marker({
position: positionMarker,
map: map
});

Show the object frmMap


This all works well with just one Lat/Lon coordinate, but what I want is that all Lat/Lon positions are marked on the map!
Of course I can modify the Javascript code in something like this...

for (var i=0; i < _DWPub.Base_Count; i++) {
positionMarker = new google.maps.LatLng(_DWPub.Base_PosLat[i], _DWPub.Base_PosLon[i]);
marker = new google.maps.Marker({
position: positionMarker,
map: map
});
}


... and I presume this may work, but how do I get the list of data echoed from the PHP-script, into an array in Opus?

Hope it's more clear now... and if not, just blame it on me 8)

Jan

_________________
"World War II Allied Aircraft Crashes in the Netherlands & North Sea" (Made with Opus Pro 9.75), available via https://www.airwar4045.nl


For this message Jan has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: June 1st, 2017, 9:42 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Okay, so I can see that all the rows are return to Opus as a single string but what I cannot figure out is why they are concatenated with a HTML Line Break character <BR>.

Your PHP...

Code:
while ($stmt -> fetch())
{
$BaseData .= "&Base_PosLat=" . $Base_Lat . "&Base_PosLon=" . $Base_Lon . "&Base_USAAF=" . $USAAF . "&Base_RAF=" . $RAF . "&Base_InUse=" . $InUse;
}
echo $BaseData;


..should simply concatenate the values right of $BaseData.= over and over for all returned rows. Where is the line break code coming from?

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: June 1st, 2017, 3:50 pm 
Offline

Joined: August 22nd, 2005, 11:56 am
Posts: 125
Location: The Netherlands
Opus: Pro 9.75 (Build 16749)
OS: Windows 10 Pro 64-bit
My mistake... Had added a <BR> to test some things and forgot to remove the line break... It's gone now and the code is as listed :wink:

Jan

_________________
"World War II Allied Aircraft Crashes in the Netherlands & North Sea" (Made with Opus Pro 9.75), available via https://www.airwar4045.nl


For this message Jan has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: 'InternetPostData is not a function' error
PostPosted: June 1st, 2017, 5:29 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Okay, the solution may depend on how many rows of data you can expect to return. If it's a lot, then joining them into one long string might not work.

In which case you'll have to write a PHP script that returns just a count of the number of matches and then another that returns them one at a time using a loop in Opus.

If you think the return string will be okay, then you simply need to join each row with a specific marker - like you did with the Line Break. Something like a semicolon or pipe.

The return in Opus will just be to a single variable. You can then use the JavaScript split function to turn the string into an array full of the rows.

myArray = myString.split(";")

You can then continue to split the elements of that array to get the data pairs ("&") and split them again to get the individual values ("=") if necessary.

You may find it easier to adjust the $BaseData .= concatenation not to use the ampersand (&) as this is really for Opus to handle an object return.

Out of interest what is the code for the original OpusScript solution for handling multiple rows.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group