[support] refreshing jcarousel item list without page reload
Christopher M. Jones
cjones at partialflow.com
Thu Nov 18 15:26:57 UTC 2010
Ahh... because it's not a function. I was slapping out that code off the
top of my head, just to give you the gist. Guess I was thinking of
JSON.parse and mixing it up with the php function json_decode(). Maybe
Drupal.parseJson()? Check this out:
http://drupal.org/node/305747
Also, you gotta listen to me, brother. This code is bad:
global $base_url;
...
$base_url/sites/default...
You've got to use the API for this stuff. Pick from any of the following:
$items, '<img src='.url('sites/default/files...').'>';
$items, theme('image', url(...)),
$itmes, theme('imagecache', 'preset', $filename),
And check the api documentation for those functions before using them.
Accuracy not guaranteed
On 11/18/2010 10:08 AM, Aldo Martinez Selleras wrote:
> I have this function callback
>
> function classification( $a = NULL ) {
> global $base_url;
> $awards = profile_award('1');
> $n = count($awards);
> $items = array();
> for ( $x = 0; $x< $n; $x++) {
> array_push($items, "<img
> src=\"$base_url/sites/default/files/viewer/objects/backgrounds/" .
> $awards[$x]['background'] . "\" width=\"75\" height=\"75/>");
> }
> print drupal_json($items);
> }
>
> And when the select option change, it call this function:
>
> function refresh_award() {
> $.get('/classification/', function(data){
> var node = JSON.decode(data);
> console.log( node ); // open firebug console to see the data
> });
> };
>
> But in firebug console I'm receiving this
>
> JSON.decode is not a function
> var node = JSON.decode(data);
>
> why?
>
More information about the support
mailing list