Hi Andy,

Neat idea. What you want for remote data is JSONP, which just requires that
your server produce a chunk of javascript that calls a function with a
specified name and passes in your data as a JSON block. So instead of
generating an HTML fragment, your data.cfm would take a parameter called
jsoncallback, and generate code like:

<value of jsoncallback paramater>({ data: "my html fragment"});

Then in jQuery you do:

$.getJSON("http://www.commadelimited.com/code/whiskerino/data.cfm?jsoncallback=?
",{
username:options['username'],
size:options['size']
}, function(data){
$targetDiv.html(data.data).cycle('fade');
});

However, having said all that, since your script is already a remote
JavaScript, my suggestion is just to make your js file be dynamic and
include the data in it directly. Then your users could just specify their
options in the url to your javascript file, like so:

<script language="javascript"
src="http://www.commadelimited.com/code/whiskerino/whiskerino.js?username=creole&divID=theDiv
" type="text/javascript"></script>

And you would generate a script with the proper data already included
directly in the script. Something like (in your generated whiskerino.js):

$(document).ready(function(){
$('#<value of divID parameter>').html("<everything you currently have in
data.cfm>").cycle('fade');
});

Or if they didn't supply a username, you could render an error message
instead:

$(document).ready(function(){
$('#<value of divID parameter>').html('<div style="color: red">Please
indicate your Whiskerino moniker.</div>').cycle('fade');
});

Also, if you don't do it like I'm suggesting, I suggest that you at least
wrap the whole thing in a function instead of requiring a global object
called "options". In whiskerino.js have something like:

function whiskerino(options) {
  $(document).ready({
   /* your code */
  });
}

And  then your users include your your script and call your function and
pass in their options:

<!-- start: copying here -->
<script language="javascript" src="
http://www.commadelimited.com/code/whiskerino/whiskerino.js";
type="text/javascript"></script>
<script type="text/javascript">
<!--
whiskerino({
username:'creole'
//,size:'m' // options are t, s, m, l or o | defaults to 'm'.
// ,divID:'whiskerino', // optional, but will look for a div called
'whiskerino'
});
//-->
</script>
<!-- end: copying here -->

But the dynamic script way that I suggested would fix that too.

Hope it helps.

--Erik


On 12/8/07, Andy Matthews <[EMAIL PROTECTED]> wrote:
>
> I'm participating in an event in which you post photos of yourself
> each day ( http://www.whiskerino.org/2007/creole/). The organizer of
> the event created RSS feeds for each participant. I thought it would
> be fun, and a good challenge to write a photo gallery using the Cycle
> plugin that could be used by any of the participants (http://
> www.commadelimited.com/code/whiskerino/slideshow.cfm).
>
> It works great on my server, but I mistakenly assumed that the local
> reference data.cfm (the file that does the work) made in the JS file
> would always be made on my server. I just tried it locally and I'm
> getting the dreaded cross domain XmlHttpRequest error. I want this to
> work without the user have to install any code, or even have a hosting
> company that offers a scripting language. I wonder now if this is even
> possible.
>
> On data.cfm, I'm using ColdFusion to read in the RSS feed, then I'm
> looping over the feed and outputting the contents into div tags. You
> can see the results here:
> http://www.commadelimited.com/code/whiskerino/data.cfm
>
> Can any of you suggest an alternate method that would work?
>

Reply via email to