SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    update page with results in php through javascript

    Here is the code i am trying to update the page and display the results in
    div section of html using javascript but i am getting an error message. Any help would be appreciated. Thank you for you help.

    Error Messge:
    Line: 36
    char: 1
    Error: Object expected
    Code: 0

    Javascript Code:
    <head>
    <script type="text/javascript">
    function results_data(id) {
    //alert(id);
    $(#results).load("retrive_information.php?appaccid="+id);
    }
    </script>
    </head>

    Html Code:
    <form id="usernames"><table align="center" width="95%"><tr><td><table><tr><td><a href="#" onClick="results_data('1')" style="text-decoration:none"><font color="black">ADMIN1</a></td>
    <td>&nbsp;</td><td><a href="#" onClick="results_data('2')" style="text-decoration:none"><font color="black">ADS</a></td>
    <td>&nbsp;</td></tr></table></form><tr><td>&nbsp;</td></tr><tr><td><div id="results"></div>

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Is jQuery being included before you include your script that has the results_data() function?

    (Since you're using jQuery syntax style code, you'll need to include the library before you can use its functionality.)
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now i updated the script as mentioned with jquery.js file. when i click on the
    href click i get a message with the ID number being displayed but then i get another message as:

    Error Messge:
    Line: 11
    char: 2
    Error: Object expected
    Code: 0


    <script type="text/javascript" src="scripts/jquery.js"></script>
    <script type="text/javascript">
    function results_data(id) {
    alert(id);
    $("#results").load("retrive_information.php?appaccid="+id);
    return false;
    }
    </script>


    Thanks for helping me once again in advance. The line 11 belongs to
    $("#results").load("retrive_information.php?appaccid="+id);
    i am not sure what object it is refering to in line 11 the results is already defined and so is the php file which displays the results when entired directly in the url location.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    This is what is supposed to retrieve the object

    $("#results")

    But the web browser is instead getting undefined, which causes the "Object expected" error.

    Please confirm that the jquery library is loading correctly. If need be, direct us to a test page so that further diagnosis may be performed.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "Please confirm that the jquery library is loading correctly"

    How do i confirm if the jquery library is loading correctly. please help me
    i am new to Javascript programming. Thank you!.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shirt View Post
    How do i confirm if the jquery library is loading correctly. please help me
    i am new to Javascript programming. Thank you!.
    The best way is to show us what you've got, by linking us to your page that's experiencing the problem.

    If you can't do that, you need to work out why $("#results") is not giving you an appropriate object, for which the only viable reason is that jquery is not loaded, most likely due to it not existing.

    But we cannot confirm that until we can investigate a test page of yours, which leads once again to linking us to your page that's experiencing the problem.

    Allow us to troubleshoot the page for you.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you!!! PMW57, You were correct the Jquery was not being loaded because of the path. i fix it using firebug and now the results loads without refresh on the DIV html tag which has the ID results.

    Thanks to PMW57 and AussieJohn for helping me.


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
  •