Tagged: javascript, script
-
AuthorPosts
-
January 29, 2014 at 12:09 am #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>
January 29, 2014 at 12:16 am #216101Hey 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,
DevinJanuary 29, 2014 at 1:25 am #216159i 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.
January 29, 2014 at 1:34 am #216165Hey!
You can use a custom [shortcode], this tool comes handy for that: http://generatewp.com/shortcodes/
Regards,
JosueJanuary 29, 2014 at 1:56 am #216179even with this tip i can’t get it to work. it seems that wordpress is always stripping the javascript.
January 29, 2014 at 2:05 am #216184Try this plugin: http://wordpress.org/plugins/insert-javascript-css/
Cheers!
JosueJanuary 29, 2014 at 10:55 am #216301i already tried this plugin. it’s not working!
January 29, 2014 at 11:09 am #216311Hi!
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!
PeterJanuary 29, 2014 at 5:27 pm #216483i 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?January 29, 2014 at 5:42 pm #216496January 29, 2014 at 5:52 pm #216510Hi!
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!
PeterJanuary 29, 2014 at 6:24 pm #216533the URL is http://mobilerevolution.ch/new/
the table should be displayed right above the map.January 29, 2014 at 7:14 pm #216555Hey!
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,
DevinJanuary 29, 2014 at 7:16 pm #216559i already tried going through a regular page with wordpress visual editor, but it doesn’t show.
what else could i try?January 29, 2014 at 7:31 pm #216575Hi!
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!
PeterJanuary 29, 2014 at 11:21 pm #216667it 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/January 30, 2014 at 9:11 am #216848Hi!
Please contact the script developer and ask him to look into it. I don’t know why it’s not working.
Best regards,
Peter -
AuthorPosts
- The topic ‘javascript JSON’ is closed to new replies.