Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I currently have an assignment that is really pushing my limits so I need some help on how to approach this.

  1. We have a set of 25 results
  2. We are using a jquery plugin to vertically scroll through these 25 results, the container displays five results at a time.
  3. When viewing the source code of the page, you can see the html for all 25 results. Obviously the jquery plugin is what is making them visible or not.
  4. The task is to make it so that only five of the result set are displaying at any time during a source code viewing. All the rest of the results must come from javascript or some other technique.

So I somehow have to either:

  1. Send a pool of 25 results to JS and have it generate the div info on the fly OR
  2. Some type of timed script that grabs five results at a time and displays them. But this all has to continuously scroll vertically so that is a consideration also.

So I am trying to get my head around how I should approach this: One idea I had was to run an ajax call every five or ten seconds that has a php script generate five new results, then display them in the appropriate div. This is slow and would basically mean a page that is constantly sending out ajax calls. the random results are coming from a php script that is parsing an xml feed.

I am really just looking for a roadmap or some conceptual directions on how this could be approached.

share|improve this question
    
So what you want is "5 elements present in the DOM at any given time", as opposed to "25 elements in the DOM but all except 5 hidden via CSS"? This sounds like performance optimisation. –  Kos Oct 6 '13 at 16:39
add comment

1 Answer

up vote 3 down vote accepted

This is not a Obfuscation issue. Obfuscation is when you let the user see the code but try to make it difficult to understand.

I think your option 1 works best.

Don't load any of the results to the Page using server side code that generates HTML. Make an AJAX Call to dynamically get and add the results to the page at run time. Since you are Uning JQuery See jQuery.ajax()

NOTE: There is no way to allow a Good hacker to viewing your results on screen while eliminating his ability to programtically get the results.

share|improve this answer
    
Yes, already using jquery ajax and I am already working your answer with good results. Seems like I can have ajax call the script to get the results, then parse the return into what I need an use something like .append to generate results on the fly. At least that is what I am working with at the moment. Comments on obfuscation and good hackers noted! –  absentx Feb 20 '12 at 19:29
1  
Even a very moderate hacker would be able to see what's going on using some kind of DOM inspection utility. –  Donal Fellows Feb 20 '12 at 20:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.