![]() |
# 1 |
חבר בקהילה
|
עזרה | קוד jquery
שלום חברים,
יש לי קוד שלוקח נתונים(rss) מאתרים אחרים. אני רוצה שמכל אתר, הקוד ייקח את מקסימום הפריטים, ויחלק אותם ל-divים, כשבכל דיב- 2 כתבות בלבד. ובעזרת כפתורים, גולשים יוכלו להעביר קדימה ואחורה כתבות, כשיש כל פעם הסתרה והופעה של דיב אחר. כרגע הקוד לוקח רק 2 פריטים מכל מקור. קוד:
<script type="text/javascript"> function get_rss_feed() { //clear the content in the div for the next feed. $("#feedContent").empty(); //use the JQuery get to grab the URL from the selected item, put the results in to an argument for parsing in the inline function called when the feed retrieval is complete $.get('proxy.php?url='+$('#diffFeeds').val(), function(d) { //find each 'item' in the file and parse it $(d).find('item').each(function(i) { //name the current found item this for this particular loop run var $item = $(this); // grab the post title var title = $item.find('title').text(); // grab the post's URL var link = $item.find('link').text(); // next, the description var description = $item.find('description').text(); //don't forget the pubdate var pubDate = $item.find('pubDate').text(); // now create a var 'html' to store the markup we're using to output the feed to the browser window var html = "<div class=\"entry\"><h2 class=\"postTitle\">" + title + "<\/h2>"; html += "<em class=\"date\">" + pubDate + "</em>"; html += "<p class=\"description\">" + description + "</p>"; html += "<a href=\"" + link + "\" target=\"_blank\">Read More >><\/a><\/div>"; //put that feed content on the screen! $('#feedContent').append($(html)); return (i<1); }); }); }; </script> </head> <body> <div id="container"> <div id="ui"> <h1>Flash Feed Reader</h1> <form id="selectParser" action=""> <label>Select a feed:</label> <select id="diffFeeds" onchange="get_rss_feed();"> <option value="">Select</option> <option value="http://rss.walla.co.il/?w=/1/0/1/@rss">walla</option> <option value="http://www.bit-101.com/blog/?feed=rss2">Bit-101</option> <option value="http://feeds.feedburner.com/peterelst/">Peter Elst</option> <option value="http://www.gskinner.com/blog/index.xml">Grant Skinner</option> </select> </form> Last edited by IgalSt; 23-11-11 at 23:18.. |
![]() |
![]() |
# 2 |
מנהל פורום, עסק רשום
|
לדעתי הבעיה היא ב-proxy.php
הקוד שלך מכניס את כל הפריטים שהוא מקבל. יש לך שם לולאת for each. |
![]() |
![]() |
# 3 |
חבר וותיק
|
בוא נתחיל מזה שכדאי מאוד מאוד מאוד שתשלח את כל המידע הזה בPOST ושמאגר הכתובות הניתנות לגלישה יהיה מתוך whitelist וישלח ע"י "קוד אתר". אחרת אתה תהיה מועד לפורענות של האקרים.
דבר שני- האם באמת בדקת את קובץ ה proxy? וכמובן תבצע דיבאגינג על הקוד שלך עם console.log ועם פיירבאג. |
![]() |
![]() |
# 4 |
חבר בקהילה
|
הצלחתי לבצע מה שרציתי
baku אשמח אם תפרט כיצד לעשות שמאגר הכתובות הניתנות לגלישה יהיה מתוך whitelist וישלח ע"י "קוד אתר". |
![]() |
![]() |
חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים) | |
|
|