Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-01-2012, 10:14 AM   PM User | #1
aref
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
aref is an unknown quantity at this point
my html code just works in FireFox

Hello everyone!
I'm a new member of this forum.
Is there anyone can help me?
My html code, just works in FireFox and it doesn't work in IE or Chrome; what should I do to solve this problem?
I'm so appreciate.
I wrote my code in blew:


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="style.css" >
<script type="text/javascript" src="jquery.js"></script>

<script>
$(document).ready(function(){
content="<ul class='content-menu' id='post_list'>";
$.getJSON("data.json",function(data){
$.each(data.post,function(i,data){
content+="<li class='content-sub-menu'><div class='article'><h4 class='article-header'><a class='article-header-link' href='#tips'>"+data.header+"</a></h4><p class='article-body'>"+data.article+"</p><img class='picture' src='"+data.image+"'/></div></li>";

});
content+="</ul>";
document.getElementById('post').innerHTML = content;
});
});
</script>

</head>

<body>
<div id="post"></div>
</div>
</body>

</html>
aref is offline   Reply With Quote
Old 10-01-2012, 01:28 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 952
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
With just a cursory glance, rename your div to something that isn't a reserved word ("post").
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 10-01-2012, 02:00 PM   PM User | #3
aref
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
aref is an unknown quantity at this point
Thank you so much for your recommendation. I changed div id with another name (with "matn"). but it doesn't work in chrome browser again
I think it depend on my browser setting, isn't it?

Last edited by aref; 10-01-2012 at 02:08 PM..
aref is offline   Reply With Quote
Old 10-01-2012, 02:03 PM   PM User | #4
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 952
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
Check the data that is being returned to make sure it's in the format you are expecting.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 10-01-2012, 02:14 PM   PM User | #5
aref
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
aref is an unknown quantity at this point
which returned data? data gotten from JSon file?
if it's wrong why it work well in FireFox and now in IE?
it just doesn't work in Chrome?
when I allow script and Activex run in IE, my data shows in IE, but in Chrome browser, script is allow and it doesn't work too??!!
aref is offline   Reply With Quote
Old 10-01-2012, 03:18 PM   PM User | #6
aref
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
aref is an unknown quantity at this point
look at this:

XMLHttpRequest cannot load file:///C:/Users/hp/Desktop/Project01/main-JSon/data.json. Origin null is not allowed by Access-Control-Allow-Origin.
Profile "Profile 1" started.

I found it in my Chrome when I run my web page in it.
how can I fix it?
is there anyone can help me?
aref is offline   Reply With Quote
Old 10-01-2012, 03:30 PM   PM User | #7
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
Your page must be on a webserver (together with the JSON file) in order to enable Chrome to read the JSON file. The file:/// access is considered a cross origin request if you didn't open Chrome up with the option --allow-file-access-from-files
devnull69 is offline   Reply With Quote
Users who have thanked devnull69 for this post:
aref (10-02-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:33 PM.


Advertisement
Log in to turn off these ads.