[ jQuery function to load Rails partial? ]
I have a jQuery function that updates my data ever few seconds.
But! It's not parsing the javascript it's loading. It just calls it appropriately every few seconds, and replaces my content with unparsed javascript code.
setupMediaIndexPoller: function(organization) {
url = '/organizations/' + organization + '/media/photos_and_video'
$.PeriodicalUpdater(url, {
method: 'get',
data: '',
minTimeout: 20000,
maxTimeout: 60000,
multiplier: 2,
type: 'html',
maxCalls: 0,
autoStop: 0
}, function(data) {
$('#media_index').html(data);
});
}
I tried making the dataType: script
, but that didn't help. Any ideas?
Answer 1
You want to have this string evaluate as javascript? If so, use Javascript's eval function:
http://www.w3schools.com/jsref/jsref_eval.asp
Answer 2
Try a little of this, maybe?
type: 'get'