Adblock breaks this site

NEED HELP

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

  1. ryanboyd

    ryanboyd Forum Addict
    $25 USD Donor New

    Joined:
    May 28, 2016
    Posts:
    463
    Referrals:
    0
    Sythe Gold:
    16
    Discord Unique ID:
    203906109067493377
    Rust Player Dragon Claws Easter 2017 Extreme Homosex Potamus
    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
     
  2. 146918496

    146918496 Member
    Banned

    Joined:
    Oct 1, 2017
    Posts:
    29
    Referrals:
    1
    Sythe Gold:
    30
    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.
     
    Last edited: Oct 3, 2017
    ryanboyd likes this.
  3. Viral_

    Viral_ Grand Master

    Joined:
    Jul 21, 2017
    Posts:
    2,483
    Referrals:
    1
    Sythe Gold:
    3,211
    Discord Unique ID:
    827322595988865025
    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.
     
  4. kmjt

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

    Joined:
    Aug 21, 2009
    Posts:
    14,450
    Referrals:
    8
    Sythe Gold:
    449
    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 | >


 
 
Adblock breaks this site