Tagged: ,

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #216099

    hi there
    is there a way to insert a script (javascript) into a normal post or page? i am using the avia layout builder and tried inserting a text field in which i copied the following code, but it didn’t work. it just displays the script code as text.

    <script type="text/javascript">
    $.getJSON("http://mobilerevolution.ch/new/json/Zentrallager Zufikon.json",
        function(data) {
            $.each(data, function(key, val) {
                var tr=$('<tr></tr>');
                $.each(val, function(k, v){
                    $('<td>'+v+'</td>').appendTo(tr);
                });
                tr.appendTo('#display');
            });​
        });​
    });
    </script>
    #216101

    Hey Roman!

    You’ll need to use a plugin that will let you insert javascript appropriately into pages as the WordPress editor will typically mess with it.

    Regards,
    Devin

    #216159

    i tried several plugins, but can’t get it to work. it either just shows the text, or i can’t even insert it in the backend because the avia layout builder won’t let me.

    #216165

    Hey!

    You can use a custom [shortcode], this tool comes handy for that: http://generatewp.com/shortcodes/

    Regards,
    Josue

    #216179

    even with this tip i can’t get it to work. it seems that wordpress is always stripping the javascript.

    #216184
    #216301

    i already tried this plugin. it’s not working!

    #216311

    Hi!

    Please try this plugin: http://wordpress.org/plugins/insert-html-snippet/ – I know some users already use it with Enfold and it works fine for them.

    Cheers!
    Peter

    #216483

    i also tried this one and it doesn’t work. i just can’t insert any code.
    can someone please give me some support? i would provide you with admin access and i could even pay you something! i need to solve this as soon as possible.
    what i try to achieve: i have a json file on the server with data in it. now i need to publish this data in a page inside a table. anyone who can help me out?

    #216496

    Hello!

    You can request a customization quote here.

    Cheers! 
    Josue

    #216510

    Hi!

    Can you post a link to your website please (where you embedded the js code with: http://wordpress.org/plugins/insert-html-snippet/ ). Maybe the code doesn’t work because you didn’t create an html element with the id “display”?

    Cheers!
    Peter

    #216533

    the URL is http://mobilerevolution.ch/new/
    the table should be displayed right above the map.

    #216555

    Hey!

    It looks like the script is in fact loading but its not executing because of an error. Have you tried it on a regular html site/page and verified it works there? You can also try going through the regular WordPress visual editor and verify it works there before adding to a text element in the avia layout builder.

    Best regards,
    Devin

    #216559

    i already tried going through a regular page with wordpress visual editor, but it doesn’t show.
    what else could i try?

    #216575

    Hi!

    The js code is part of the website source code and it’s not a problem with the theme or the “insert-html-snippet” plugin. You can check the source code of the page by yourself – i.e. search for

    
    <div class='avia_textblock '  itemprop="text" ><script type="text/javascript">
    $.getJSON("http://mobilerevolution.ch/new/json/Zentrallager Zufikon.json",
        function(data) {
            $.each(data, function(key, val) {
                var tr=$('<tr></tr>');
                $.each(val, function(k, v){
                    $('<td>'+v+'</td>').appendTo(tr);
                });
                tr.appendTo('#display');
            });​
        });​
    });
    </script>
    </div>
    

    I think it doesn’t work because you didn’t create a div with the id “display”. I suggest to replace

    
    <script type="text/javascript">
    

    with

    
    <div id="display"></div>
    <script type="text/javascript">
    

    and then the code should work…

    Cheers!
    Peter

    #216667

    it still doesn’t show the content. i placed the div tag in front of the script tag. i also tried putting the script inside the div tag. no success. do i have to define the div tag “display” with some css?
    i also have another page on which a widget from shopify should be shown through some javascript. the same problem here. http://mobilerevolution.ch/new/selber-reparieren/

    #216848

    Hi!

    Please contact the script developer and ask him to look into it. I don’t know why it’s not working.

    Best regards,
    Peter

Viewing 17 posts - 1 through 17 (of 17 total)
  • The topic ‘javascript JSON’ is closed to new replies.