473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

jquery image not loading from array in php

116 100+
i have the jquery loading the image gallery part as follows

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function mycarousel_itemLoadCallback(carousel, state)
  4. {
  5.     // Check if the requested items already exist
  6.     if (carousel.has(carousel.first, carousel.last)) {
  7.         return;
  8.     }
  9.  
  10.     jQuery.get(
  11.         'dynamic_ajax_php.php',
  12.         {
  13.             first: carousel.first,
  14.             last: carousel.last
  15.         },
  16.         function(xml) {
  17.             mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
  18.         },
  19.         'xml'
  20.     );
  21. };
  22.  
  23. function mycarousel_itemAddCallback(carousel, first, last, xml)
  24. {
  25.     // Set the size of the carousel
  26.     carousel.size(parseInt(jQuery('total', xml).text()));
  27.  
  28.     jQuery('image', xml).each(function(i) {
  29.         carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text()));
  30.     });
  31. };
  32.  
  33. /**
  34.  * Item html creation helper.
  35.  */
  36. function mycarousel_getItemHTML(id,url)
  37. {
  38.     return '<img src="' + url + '" width="75" height="75" alt="" />';
  39. };
  40.  
  41. jQuery(document).ready(function() {
  42.     jQuery('#mycarousel').jcarousel({
  43.         // Uncomment the following option if you want items
  44.         // which are outside the visible range to be removed
  45.         // from the DOM.
  46.         // Useful for carousels with MANY items.
  47.  
  48.         // itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
  49.         itemLoadCallback: mycarousel_itemLoadCallback
  50.     });
  51. });
  52.  
  53. </script>
i want that the images should be loaded from the array in php holding the location of the images . my php script is as follows

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4. // Array 
  5.  
  6.  
  7. $total = -1;
  8.  
  9. $images = array();
  10. $query = "SELECT images_list.loc FROM images_list ";
  11.     $result = mysql_query($query);
  12.     confirm_query($result);
  13.     $images[]=" ";
  14.         while ($record = mysql_fetch_assoc($result)) {
  15.           $images[] = $record['loc'] ;    
  16.  
  17.           }
  18.           $total    = count($images); 
  19.           $selected = array_slice($images, $first, $length);
  20.  
  21. // ---
  22.  
  23. header('Content-Type: text/xml');
  24.  
  25. echo '<data>';
  26.  
  27. echo '  <total>' . $total . '</total>';
  28.  
  29. foreach ($selected as $img) {
  30.     echo '  <image>' . $img . '</image>';
  31. }
  32.  
  33. echo '</data>';
  34.  
  35.  
  36.  
  37. function confirm_query($r) {
  38.         if (!$r) {
  39.             die("Database query failed: " . mysql_error());
  40.         }
  41.     }
  42. ?>
  43.  

but the images don't load into the gallery....someone plz help
Apr 23 '12 #1
1 2029
johny10151981
1,059 1GB
I didnt read your code. it wont take me anywhere, I would rather suggest you something.

say x.php would be called by ajax request, and it would return an array to the client. here how you can achieve it:

in x.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $a[0]='data1';
  3. $a[1]='data2';
  4. $a[3]='data3';
  5. $a[4]='data4';
  6. echo "<script>";
  7. echo "var jarray=new Array()";
  8. for($i=0;$i<count($a);$i++)
  9. {
  10.  echo "jarray[".$i."]='".$a[$i]."'";
  11. }
  12. echo "</script>";
  13. ?>
  14.  
in jquery success
Expand|Select|Wrap|Line Numbers
  1. $("#some_hidden_div").html(returned_text_by_PHP);
  2.  
  3. //codes to access jarray
  4.  
at this stage you have the array in a usable status,
Apr 23 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: OneSolution | last post by:
Hi All, Here's what I'm trying to do. I have a diverse customer base, and as it grows, it's increasingly harder to figure out what aspect of our web site is selling and what is not. So I've...
2
by: Wonko | last post by:
Here's my problem if anyone could be so kind to help me out. I assume it's quite easy for an experienced programmer but I'm not one of them :) I have a JavaScript code that: - displays multiple...
2
by: Mekon | last post by:
I have never written a line of script in my life but I need some help with it now. I have this auto generated code which I want to modify if possible The script generates a strip of...
4
by: zborisau | last post by:
Hey good people, I've been given a problem to solve recently - and stuck with the solution for a good 4 days already. i have a link which leads to popup window. the purpose of that popup...
7
by: chris | last post by:
Firefox seems to be restricting JavaScript image loading. The following code works fine in all browsers except Firefox: function loadImage() { var objIcon = document.createElement( 'IMG' );...
1
by: byroncheung | last post by:
i have my own slideshow player (really simple one, which has no image pre-caching) which when it try to change the picture, it simply do a : document.images.show.src = file; and then wait for a...
4
by: Sophy | last post by:
Hi folks, Now, I am facing problem with canceling image loading. I have tried: var img = new Image(); img.src = "path/to/the/image"; // and then I set the img.src to another source
1
by: krishnaraj suresh | last post by:
Hi , I am facing problem with Loading an Image in an aspx page It is taking long Time to Load But once the Image stored in Client-side Cash it is Loading Fast. Is there any way to Store the Image...
6
by: aaronkmar | last post by:
Trying to get a loading image to spin while the query is loading. I can get the data div to fade in, but I can't seem to figure out how to get the gif while the query is loading. I'm using two...
0
by: Magda Balise | last post by:
http://www.san-juan-island.net/testSite I am very close to finishing this site as a matter of fact I thought I was done until after checking all the browsers I found IE was not working correctly....
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.