Jump to content

[SOLVED] need help understanding this code


thisisnuts123

Recommended Posts

function onDrop() {
          var data = DragDrop.serData('g1');
          x_sajax_update(data, confirm);
<?php
$hello = update_dropbox();
?> 
var l="<?php echo $hello; ?>";	
        alert(l);
}

 

 

above code is a javafuntion which is calling the php funtion update_dropbox(); this funtion then return a variable.. if i check my debuger up to this point it;s good

but now $hello = update_drop()' seems to return nothing..

so when i alert empty box pops out.. is there another way to get value out of the update_dropbox();

i tested

 

function getId()
  	{
	 var x=document.getElementById("dropBox");
var dropboxid=DragDrop.getDropBoxid('g1', null);
alert(dropboxid);
<?php
$Boxid = "thisisatest";
?>
var s="<?= $Boxid ?>";
alert(s);
  	} 

 

and i actualy get a alert says thisis a test.. so i guess there is someting wrong with $hello = update_dropbox(); part of the code can any one help me with this?

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/73393-solved-need-help-understanding-this-code/
Share on other sites

PHP has long been processed (server side) prior to any javascript (client side) function being called. You really need to rethink your entire logic. Maybe look into some Ajax tutorials.

 

In order to have javascript (client side) execute a php (server side) function you need to make another request to the server.

 

There is a great little ajax tutorial here written by the guy who wrote the first versions of php.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.