fail to set session storage in dynamic list view by using json & ajax

fail to set session storage in dynamic list view by using json & ajax

Hi all,
     I am trying to show a listview using json data. i want to set url for each row using sessionStorage() but i was failed to set


my code is

  1. <!DOCTYPE html> 
  2. <html>
  3. <head> 
  4. <title>categories</title> 
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"> 
  6. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
  7. <!--<link rel="stylesheet" href="main.css" />-->
  8. <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
  9. <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
  10. <script src="load.js" type="text/javascript" ></script>
  11. </head> 
  12. <body>
  13. <!-- Main Page -->
  14. <div data-role="page" data-theme="a" id="cList">
  15. <!-- Logo -->
  16. <div data-role="header">
  17. <a href="#" data-rel="back" data-add-back-btn="true" data-back-btn-text="Back" data-direction="reverse">back</a>
  18. <h1>categories</h1> 
  19.         </div>
  20. <div data-role="content" id="categoryList">
  21. <!-- No results warning (initially hided) -->
  22. <div id="notfound"><h5>no results found</h5></div>
  23. <!-- Results container -->
  24. <ul id="catResults" data-role="listview" data-inset="true" data-filter="true" data-theme="c">
  25. </ul>
  26. <!-- Ajax loader -->
  27. <div id="loader"><h4>Loading...</h4></div>
  28. </div>
  29. </div>
  30. <!-- end Main Page -->

  31. <script>
  32. $( document ).delegate("#cList","pagebeforecreate", function() {
  33.     
  34.     alert('catgories page');
  35.                 categories();
  36.                   
  37.                  });
  38. </script>
  39. <!-- end Detail Page -->
  40. </body>
  41. </html>
     
and js code is



  1. function categoryCallback(data) {
  2. alert('under catgory call back');
  3. //Checks if search have results
  4. //Ajax loader is hided
  5. $("#loader").hide();
  6. $("#catResults").empty();
  7. alert('before foreach');
  8. alert('data is'+data);
  9. //<ul id="catResults" data-role="listview" data-inset="true" data-filter="true" data-theme="c">
  10. var ouput = '';
  11. // ouput+=
  12. $.each(data, function(index, category) {
  13. //Stores element id
  14. //alert('be foreach');
  15. var catgoryId = category.id;
  16. //alert('category id is'+catgoryId);
  17. //Change the default 'not found' poster
  18.   var catgoryName = category.cName;
  19. catCouponUrl="http:\/\/www.morenmoredeals.com\/ws\/api\/Json.php?data=cByCategoryNew&id=";
  20. //
  21. //$("#catResults").append('<li><a onclick="'+
  22. // 'sessionStorage.setItem(\"key\",'
  23. // +encodeURIComponent(catCouponUrl)+
  24. // category.id+
  25. // '");" href="#">'+
  26. // '<h3>'+category.cName+'</h3>'+
  27. // '</a></div></li>');
  28. ouput += '<li><a onclick="sessionStorage.setItem("key","';
  29. //ouput+=catCouponUrl+category.id;
  30. ouput+="http://www.morenmoredeals.com/ws/api/Json.php?data=cByCategoryNew&id=";
  31. // ouput+=catCouponUrl;
  32. //ouput+=category.id;
  33. ouput+=");";
  34. ouput+='<h3>';
  35. ouput+=category.cName;
  36. ouput+='</h3>';
  37. ouput+='</li>';
  38. });
  39. ouput+='</ul>';
  40. $('#catResults').html(ouput).listview("refresh");}
  code is working fine but i am getting output html as follows
  1. <a json.php?data="cByCategoryNew&amp;id=);&lt;h3" api="" ws="" www.morenmoredeals.com="" key","http:="" onclick="sessionStorage.setItem(" class="ui-link-inherit">Apparel/Clothing</a>
  but my intesion is to get output like this

  1. <a onclick="sessionStorage.setItem("key","http:www.morenmoredeals.com/ws/api/Json.php?data=cByCategoryNew&id=100");  class="ui-link-inherit">Apparel/Clothing</a>
my problem is  i fail to set function and url properly

can any body please help me



thanks and regards


vara prasad