-1

Here what I exactly need is, if I move over the HTML button, specific div tag should be reloaded without reloading whole page.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Beena Gates
  • 75
  • 1
  • 2
  • 11

2 Answers2

1

PHP works on the server side, and JavaScript on the client side. So to do this, you would have to make a request to the server. If you want to use plain JavaScript, take a look at Ajax:

http://www.w3schools.com/ajax/

<script>
function myPhpFunctionCall()
{
  var xmlhttp;
  xmlhttp=new XMLHttpRequest();

  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      // Do something with the results here
    }
  }
  xmlhttp.open("GET","my_function.php",true);
  xmlhttp.send();
}
</script>

Or, if you want to use jQuery, you can use their get method:

<script>
    $.get('http://yourdomain/your_script.php');
</script>
Jorick Spitzen
  • 1,559
  • 1
  • 13
  • 25
  • 1
    If you could provide some code supporting your answer, it would form a better answer. Just links in the answer, may make it non useful, if the links get modified in the future. – Prerak Sola Jun 11 '15 at 11:03
  • 1
    I would love to add a code example, but since the question does not really give a specific task to solve, I really can't add a more useful than the code example on page 1 of that w3schools tutorial... – Jorick Spitzen Jun 11 '15 at 11:08
-3

Simple way to solve this any of your function in place of json_encode() :

$(document).ready(function() {

         var php_var = '<?php echo json_encode($form); ?>';          

});


$('#element').hover(function() {

         $('#form_container').html(php_var);
}, function() {

         $('#form_container').html('');
});
viralchampanery
  • 397
  • 1
  • 7
  • 16