0

I'm trying to load an php file through ajax using load(). Here's my code:

var loadUrl = "myfile.php";                             
$("#lst-results").load(loadUrl);

So, when I do this, it works:

<?php   
$test = 'Hi :3';    
?>
<h3>Hi</h3>
<h3><?php echo $test ?></h3>

But I need to include a file that contain a lot of includes and functions using a lot of different classes. I've tryed to include this file and use it as a function like this, but does not work and Nothing appears int the load() results. This function return an array.

<?php
include 'path/myfile.php';
$result = myFunction(); 
?>

I can't figure out how to solve it. :(

Samy
  • 1
  • 1

1 Answers1

0

You need to "echo" the $result.

<?php
    include 'path/myfile.php';
    $result = myFunction();
    echo $result;
Peter Pajchl
  • 2,699
  • 21
  • 24
  • If the function returns array, it won't work. You need to return HTML markup in some form. Can you post the myFunction() script? – Peter Pajchl Nov 13 '12 at 20:09
  • Just one question to you: `Do you want to invoke php functions via JavaScript?` – Yang Nov 13 '12 at 20:20