NEED HELP

Discussion in 'Web Programming' started by ryanboyd, Sep 25, 2017.

NEED HELP
  1. Unread #1 - Sep 25, 2017 at 9:22 PM
  2. ryanboyd
    Joined:
    May 28, 2016
    Posts:
    463
    Referrals:
    0
    Sythe Gold:
    16
    Discord Unique ID:
    203906109067493377
    Rust Player Dragon Claws Easter 2017 Extreme Homosex Potamus

    ryanboyd Forum Addict
    $25 USD Donor New

    NEED HELP

    so here is my current code

    <script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
    $('#five_year').dataTable({
    "iDisplayLength": 25
    });
    });
    </script>

    but i need to some how load a table from another html file so i can just change the file instead of refering to the html code.

    Can anyone help me?

    for example the html file being called is data.html

    thanks
     
  3. Unread #2 - Oct 3, 2017 at 9:14 PM
  4. 146918496
    Joined:
    Oct 1, 2017
    Posts:
    29
    Referrals:
    1
    Sythe Gold:
    30

    146918496 Member
    Banned

    NEED HELP

    Hey ryanboyd,
    Hopefully I can help you out.

    First off, type="text/javascript" charset="utf-8" isn't needed, js is implied by script.
    Secondly, you set the charset in <head>, (<meta charset="UTF-8" />)

    Anyways, in response to your actual question, you'll need to load it dynamically with AJAX
    $.get() jQuery
    you'd also be better off just using a json file since you can parse that directly into some json structure in JS, as it is JS Object Notation and then use dataTable with that.

    Hopefully this was helpful to you,
    If you need more assistance you're welcome to PM me.
     
    ^ ryanboyd likes this.
    Last edited: Oct 3, 2017
  5. Unread #3 - Oct 17, 2017 at 8:18 PM
  6. Viral_
    Joined:
    Jul 21, 2017
    Posts:
    2,483
    Referrals:
    1
    Sythe Gold:
    3,211
    Discord Unique ID:
    827322595988865025

    Viral_ Grand Master

    NEED HELP

    Well technically all you need to do is build an html table of with all your data. Then initialize the javascript by embedding it in the html file or including it through a js file. If you include it through a js file you do not have to have the <script></script> tags.
     
  7. Unread #4 - Oct 22, 2017 at 5:54 PM
  8. kmjt
    Joined:
    Aug 21, 2009
    Posts:
    14,450
    Referrals:
    8
    Sythe Gold:
    449

    kmjt -.- The nocturnal life chose me -.-
    Banned

    NEED HELP


    Shouldn't need to use ajax if its static data in the same file system.. just navigate the file system.

    @ryanboyd if you can use php why don't you just completely build your table (assuming its static) in your data file and then include it? This is common for static data like headers and footers. If your static data is only 25 rows personally I would just have it in your html to begin with instead of fetching it.

    Code:
    <?php include 'data.php';?>
     
< Need help | >

Users viewing this thread
1 guest


 
 
Adblock breaks this site