...

View Full Version : clipbucket javascript problem



paperino00
12-16-2011, 11:28 PM
Hello, in the channel of a user in clipbucket, down page there are the tabs "Activity", "Infos", "Videos", "Groups" and "Photos"...
When I click in Videos, Groups and Photos tabs clipbucket doesn't load and show them, could you help me solve this?
the only problem sometimes I get in javascript error consol is "The object doesn't support the method appendTo". I marked red the line with the problem in the code below here.
you can see the problem in this page, logging in with "arvixe" as username and password

removed URL (NSFW)

Thank you :)


function channelObjects(object,div,type,user,assign)
{
var obj = $(object), curRel = obj.attr('rel'),
DIV = $(div), oldRel = obj.parents('ul').find('a.selected').attr('rel');

if(curRel)
{
if($("#"+curRel).css('display') == 'block')
return false;
else
{
obj.parents('ul').find('a.selected').removeClass('selected');
obj.addClass('selected');

$("#"+oldRel).hide();
$("#"+curRel).show();
}
} else {
var newRel = type+"DIV";
obj.attr('rel',newRel);
$.ajax({
url : page,
type : "POST",
dataType : "json",
data : ({ mode : "channelObjects", content : type, user : user, assign : assign}),
beforeSend : function() { obj.append(loading_img) },
success : function(data)
{
obj.find('img').remove();
obj.parents('ul').find('a.selected').removeClass('selected');
obj.addClass('selected');

$("#"+oldRel).hide();
$("<div></div>").attr('id',newRel).addClass($("#"+oldRel).attr('class')).html(data.html).appendTo(DIV);
}
})
}

venegal
12-17-2011, 05:50 PM
You're obviously expecting the request to return JSON, and that data is an object. It's not though (use your browser's debugging tools) data is a string, so data.html is undefined.

So, when calling .html(data.html), you're actually calling .html(undefined), which is the same as passing no parameter at all. If no parameter is passed, though, jQuery's html won't set the HTML and return the object, but get the HTML.

This means that it returns a string, which obviously doesn't have an appendTo method.

paperino00
12-20-2011, 10:23 PM
I checked the official clipbucket demo and the function is exactly like mine so the problem isn't there and i don't know why it doesn't show them...
I don't know json can you explain me how it works, there must be somewhere a php code associated with that javascript function and causing the problem?

thank you!

venegal
12-20-2011, 10:38 PM
What I meant is: Your code makes an AJAX request to ajax.php, and tries to handle the response as JSON. The response isn't JSON, though, it's gibberish. As I said, use your browser's debugging tools to see the AJAX response, and debug your PHP code, so it actually sends JSON (meaning a serialized Javascript object google it, if you don't know what that means).

paperino00
12-23-2011, 01:54 AM
I debugged the json response that is:

Fatal error: Cannot use assign-op operators with overloaded objects nor string offsets in /home/mysite/public_html/ajax.php on line 1154.

In clipbucket official demo it response correctly despite the code seems the same...

this is part of ajax.php, I evidenced in red the line 1154, do you see something wrong? I didn't coded it and I'n not expert so i can't get out what's wrong...
Thank you! ;)


switch($contentType)
{
case "videos" :
{
$videos = get_videos(array("user"=>$u['userid'],"order"=>" date_added DESC","limit"=>config('videos_item_channel_page')));

if($videos)
{
foreach($videos as $video)
{
assign('video',$video);
assign('channelVideo',true);
$content['html'] .= Fetch("/blocks/video.html");
}
$content['html'] .= '<div align="right" class="clearfix channelAjaxMoreLink videosMoreLink" style="clear:both; display:block;">';
$content['html'] .= '<a href="'.cblink(array("name"=>"user_videos")).$u['username'].'">'.lang('more').'</a> | <a href="'.cblink(array("name"=>"user_favorites")).$u['username'].'">'.lang('Favorites').'</a>';
$content['html'] .= '</div>';
} else {
$content['html'] = '<div align="center"><em>'.lang('user_have_no_vide').'</em></div>';
}
}
break;

venegal
12-23-2011, 10:18 AM
It seems $content isn't what you think it is, but there's no way to know without seeing more of the code. If you need further help with this, please post in the PHP section of the forum.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum