So, i'm trying to write a script that will check my various wordpress installs and see if they have any updates that are needed. I've already built a plugin that will display some JSON if you post the password to a wordpress page.
The problem, is that everytime it loops through my websites, it pulls the same exact data everytime, even tho i know it should be different!
function repeatMe( ){
var places = ["website1.com", "Website2.org", "Website3.com", "Website4.com", ];
i = typeof(i) == 'undefined' ? 0 : i + 1;
$.ajax({
url: places[i],
method: 'POST',
data: { 'login' : 'password' },
dataType: 'jsonp',
cache: true,
timeout: 4500,
success: function(data) {
$('tr#'+i+' td.lastconn').text( data.title );
console.log(data.title);
setTimeout(repeatMe, 5000);
},
error: function(){
$('#output').html('<span style="color:red;">Error</span>');
setTimeout(repeatMe, 5000);
}
});
if (i == places.length - 1) {
i = -1;
}
}
setTimeout(repeatMe, 5000);
I'm fairly new to Javascript, so forgive any egregious attempts to patch it together; I'm open to instruction.
You'll see the data.title piece. It returns it the first time correctly, and then after that, it just uses the same value every time. What am I doing wrong?
JSONP Attempt
I noticed that the only data it pulled correctly was from it's own domain. And so I used this answer: Make cross-domain ajax JSONP request with jQuery
UPDATE: JSONP is now doing the same thing that the standard was doing before. Still getting data from the local domain, but then just repeating that same data when it reaches out to any other domain. No Dice :(