Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

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 12-16-2011, 06:23 AM   PM User | #1
capypara
New Coder

 
Join Date: Aug 2011
Posts: 49
Thanks: 1
Thanked 0 Times in 0 Posts
capypara is an unknown quantity at this point
Cant display image in div element

I am trying to show the user's picture when they press a submit button, but the picture does not show up. Is it even possible for images to be displayed in a div?

Code:
Javascript
    function show_message()
    {
        $.post(site_url},
        		function(data)
        		{
        	        $('<img>', {src: source of pic}).appendTo($('#chatContents'));
        	    }, "json");
    }

HTML
    <div id="chat-wrap">
        <div id="chatContents"></div>
    </div>
capypara is offline   Reply With Quote
Old 12-16-2011, 07:15 AM   PM User | #2
Finch
New to the CF scene

 
Join Date: Dec 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Finch is an unknown quantity at this point
While I personally don't have the answer for you, as I am still developing my JavaScript skills, you can check out this link (if you haven't already) where another user was trying to do something very similar:
http://www.designerstalk.com/forums/...avascript.html
Finch is offline   Reply With Quote
Old 12-16-2011, 08:12 AM   PM User | #3
capypara
New Coder

 
Join Date: Aug 2011
Posts: 49
Thanks: 1
Thanked 0 Times in 0 Posts
capypara is an unknown quantity at this point
Sure I will take a look. Thanks for the link.
capypara is offline   Reply With Quote
Old 12-17-2011, 01:54 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,696
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Uhm, it looks like you have a syntax error:

Code:
$.post(site_url},
Also, if checking JS functionality, learn to make use of a debugging tool/error console. This would probably have notified you of the error. Firefox has a built-in error console under “Extras > Web developer” or something like that (keyboard shortcut Cmd/Ctrl+Shift+K). But there’s also the web developer toolbar and Firebug, the most popular add-on. Other browsers like Safari/Chrome or Opera have similar tools built in already.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 12-19-2011, 01:48 AM   PM User | #5
capypara
New Coder

 
Join Date: Aug 2011
Posts: 49
Thanks: 1
Thanked 0 Times in 0 Posts
capypara is an unknown quantity at this point
Oops lol. Thanks for pointing that out.

I fixed that, and i was using Firebug right from the start. I get no errors even though no images are showing up.

Last edited by capypara; 12-19-2011 at 03:06 AM..
capypara is offline   Reply With Quote
Old 12-19-2011, 05:25 AM   PM User | #6
capypara
New Coder

 
Join Date: Aug 2011
Posts: 49
Thanks: 1
Thanked 0 Times in 0 Posts
capypara is an unknown quantity at this point
Ok i solved it, stupid mistake on my part. I forgot to json encode my data in my php, which caused JS to skip the whole function together.
capypara is offline   Reply With Quote
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 05:54 AM.


Advertisement
Log in to turn off these ads.