2

I'm trying to call a php page which essentially parses my xml and if there's changes in the xml, it inserts that data into a mysql table.

My code originally was:

var auto_refresh = setInterval(
function ()
{
$('.blabla').load('parser.php');
}, 10000); // refresh every 10000 milliseconds

where .blabla was an empty div and parser.php did not echo any information - I only called the php to check the xml.

Rather than call the php every 10 seconds which seems a bit unnecessary, I want to call the php before my page loads.

How would I go about doing that?

This is what I have got so far:

$(document).ready(function() {

 $('.blabla').load('parser.php');

});

which is not working.

12
  • try to load on a id ,not a class,like #myid Commented Dec 16, 2012 at 17:14
  • that doesn't work unfortunately :( Commented Dec 16, 2012 at 17:15
  • Why are you using load() if you're not inserting content? You should be using $.get or $.ajax, which load is a convinient shortcut for, that also inserts the content! Commented Dec 16, 2012 at 17:17
  • Run firebug and look in the console - what is happening? Commented Dec 16, 2012 at 17:17
  • 2
    @naspinski - You're right, but load automagically inserts the content returned in the ajax function. If the OP is'nt inserting content, there's no need for load(). Commented Dec 16, 2012 at 18:32

1 Answer 1

1

Try

 $(document).ready(function() {

        $('.blabla').load('parser.php', function()
        {
            //just to see if you loaded the php 
            alert("loaded yay!");  
       });

    }); 

If there is no message, the problem maybe the php.

Sign up to request clarification or add additional context in comments.

1 Comment

I get no alert - hmm why would it work when i had setinterval on it though?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.