benhowdle89
benhowdle89

Reputation: 37464

Load multiple variables from PHP via jQuery AJAX request

OK, i have this jQuery script using ajax to load a response from a php file, but i want to do is to load maybe two variables from the php script rather than the whole page.

$(document).ready(function() {
 $.ajaxSetup({
    cache: false
 });
$("#object_area").load("test.php");
   var refreshId = setInterval(function() {
      $("#object_area").load("test.php");
   },10000);
});

So what i want is to be able to say load variable1 from the php page into object_area, then load variable2 into object_area2 if that makes sense?

Thanks

Upvotes: 1

Views: 792

Answers (1)

Pascal Qyy
Pascal Qyy

Reputation: 4502

What about return your variables in JSON format with the dedicated PHP function ?

(don't forget to properly set the headers)

You could manipulate your variables more simply with JQuery

Upvotes: 1

Related Questions