oh my goodness! clearly having an off day! That’s resolved that error haha Still not pulling any information through to the hype page though
So I’ve just checked the developer console in safari and I can see that it’s working just the information isn’t showing within the hype page however the button click is working and returning the correct data. Anyone got an idea how I can get this information to show within a hype element?
Looking at the code above, the first question is if the success function is being called, and if the result inside
res is as expected. Like I said before, I’d try doing a console log to see if that is the case.
Your line is this:
The first question is if results is an ID in the document? Is
I’d also guess you really want the code to be something like:
(but I think your code would probably output the raw result to that div okay)
results is the ID for the box element that I want the data to display in.
When I press the button on the live website, on console it shows that the data is being pulled from test.php but is just not showing in the ‘results’ box on the hype page.
So the function is working and its getting the information that’s needed. I just need it to be displayed on the live webpage
No warnings are showing up in the console either. Its just not displaying the information obtained from test.php within the hype element with the ID ‘results’
I would first try a simple button where you run the code to insert a simple string into the results field and verify that is working as expecting. It sounds like there is a disconnect in inserting it if indeed the success function is being triggered with the correct “res” data.
my code is similar to the one found on this feed:
However, they have managed to actually get the information to display within the hype document. I can’t really see what I’m doing wrong / different here. I just get a blank box where the data should be displayed no matter what I try.
Here’s my files so far. I’ve changed them a bit and tried a few things with still no results. I think it’s something really simple that I’m missing but I just can’t work it out. Getting data from a database to display in hype is a lot harder than I expected especially as sending data to the database was pretty simple.
data recieve from database.zip (41.5 KB)
If anyone has any solutions then I’ll be really grateful.
The zip doesn’t seem to extract for me; can you try again/a different method?
I’ve loaded both files onto drop box and created 2 share links:
The PHP file:
The HYPE file:
Hope this works and thanks again,
hi! i got success with this php and hype in combination.sqlHype.zip (104,1 KB)
have you created that on hype 4.0? I’m unable to open it on 3.6.7 as it’s saying it was created in a newer version.
sorry, ialways forget, that documents aere autosaved in newest versions.
sqlHype.zip (104,5 KB)
Thanks for this! I’ll have a play around with it to see if I can get this working on my server and then attempt to use the code for my project
great! i use it for creating a score- list automatically after finishing a game.
it´s working really cool.
When sending an Ajax request as dataType: JSON you’ll have to return (or echo out) the response as JSON as well so in your PHP file you should be using json_encode($variable) that way your AJAX success property (function) will contain the echo’d content.
There are inherent problems in my opinion though as you’re echoing out HTML too and aren’t really dealing with arrays / objects of information so JSON may not be the best in this case. Maybe look into using the dataType: HTML with AJAX.
I’m planing to use it to inform people of the last used site on the body where insulin was administered to make sure they choose a different site the next time. This is why I need data from a data base to be displayed. I’ve already created a system to send the information to the database so this should help complete the next steps of the idea development. Long way to go though!
Thanks @DBear I’ll look further into this
I’ve managed to get your example working perfectly. I was just wondering if you had managed to get more than one row of data to be received from the database to display in hype?
for example using the PHP:
$sql="SELECT * FROM $tableName WHERE id = 3 AND id = 2";
isn´t it possible using this?
$sql = "SELECT * FROM $tableName";
then you have to create a table in innerHTML of an rectangle to display the whole sql
EDIT: if you want specifical rows only - this example i never tried, sorry.
for this i´ve to test, but haven´t time yet