SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery AJAX help needed

    Quote Originally Posted by everclear View Post
    This function works nicely except it's based on an interval, how can I adapt it so it only fires once.

    Code:
    $(document).ready(function() {
    $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh
    setInterval(function() {
    $('#txtSummary').load('http://localhost/example/comp333assn1/php/group_list.php?q=all_contacts')
    }, 3000); // the "3000" here refers to the time to refresh the div. it is in milliseconds.
    });
    Hi,
    i have submitted a form and the query to retrieve the form details is in xyz.php
    when i do $('#xxx').load('xyz.php') in the above code, the query from the database is not reflected.
    kindly help,
    thanks!

  2. #2
    SitePoint Member
    Join Date
    Jun 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My form action attribute is calling abc.PHP which inserts value to the database!

  3. #3
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    There is no obvious error in the code you posted (apart from a missing semi-colon).

    What is in xyz.php?

  4. #4
    SitePoint Member
    Join Date
    Jun 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi,

    There is no obvious error in the code you posted (apart from a missing semi-colon).

    What is in xyz.php?
    It contains code to retrieve data from database.
    From firebug console I see the PHP script is not loading but only the HTML scripts are loading

  5. #5
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Without any further information, I can only suggest that it is an error in your PHP script.

    What happens if you specify a callback function that is executed when the request completes.?

    Code:
    $('#txtSummary').load('http://localhost/example/comp333assn1/php/group_list.php?q=all_contacts', function( response, status, xhr ) {
      if ( status == "error" ) {
        var msg = "Sorry but there was an error: ";
        console.log( msg + xhr.status + " " + xhr.statusText );
      }
    });
    Ref: http://api.jquery.com/load/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •