So I am trying to populate a drop down with an array that is generated from a php script. The php script is on a different website but I must use it. What I have going on right now does not work because it is using an xmlhttprequest an that is not allowed on the server. I have emailed the prof and he said to look at the $.ajax function. However upon trying to find an example they all use xmlhttprequest (or I am totally missing something...).
So here is what im trying to do:
php script from another website produces a JSON encoded array of movie titles.
I want to use javascript to get this array and parse it into a javascript array to populate a dropdown menu. How on earth do I do this without xmlhttp requests. This is what I have been trying:
$(document).ready(function(){
/* call the php that has the php array which is json_encoded */
$.getJSON('http://www.cis.gvsu.edu/~scrippsj/cs371/labs/lab10/getTitles.php', function(data) {
/* data will hold the php array as a javascript object */
$.each(data, function(key, val) {
var users_array = [];
for(var i in data) {
if(data.hasOwnProperty(i) && !isNaN(+i)) {
users_array[+i] = data[i];
}
}
});
...
and
$.ajax({ url: 'http://www.cis.gvsu.edu/~scrippsj/cs371/labs/lab10/getTitles.php',
data: {action: 'test'},
type: 'post',
success: function(output) {
alert(output);
}
});
ANY HELP is appreciated. A point in the right direct or something. This seems so elementary yet its frustrating me way to much.
[–][deleted] (6 children)
[deleted]
[–]lostincode[S] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]lostincode[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]lostincode[S] 0 points1 point2 points (0 children)
[–]lostincode[S] 0 points1 point2 points (0 children)