Partial jQuery function to load Rails?

I have a jQuery function that updates my data every few seconds.

But! It does not parse javascript loading. He simply calls it appropriately every few seconds and replaces my content with unsolved 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 to do it dataType: script, but it didn’t help. Any ideas?

+3
source share
2 answers

Do you want this string to be evaluated as javascript? If so, use the Javascript eval function:

http://www.w3schools.com/jsref/jsref_eval.asp

+3
source

Try a little, maybe?

type: 'get'
0
source

Source: https://habr.com/ru/post/1765860/


All Articles