this link returns a json data set http://nutri.de.imerchmedia.com/services/accounts but everytime I use jquery to extract the data it doesnt show heres my code
$.getJSON( "http://nutri.de.imerchmedia.com/services/accounts", function(data ) {
$('#select').append("<option value='0' name='idsel'>Select Outlet</option>");
$.each(data, function (i, item) {
$('#select').append("<option value='" + item.outlet_group_id + "'>" +
item.outlet_group_name + " : " + item.outlet_group_code + "</option>");
});
});
<div id="content">
<?php
echo '<form method="POST">';
echo '<select id="select" name="id"></select>';
echo '<input type="submit" value="Submit" name="submit"/>';
echo '</form>';
if(isset($_POST['submit'])){
echo $_POST['id'];
}
?>
</div>
That's an error, more specifically a same-origin error
http://jsfiddle.net/gyTjL/
// had to post some code
$.get('http://nutri.de.imerchmedia.com/services/accounts').fail(function(a,b,c) {
// gives -> is not allowed by Access-Control-Allow-Origin.
});
You can not make ajax requests to domains other than your own, unless JSONP is used, which isn't really ajax, it inserts a script tags, but jQuery makes it look like ajax, or if the server you're contacting supports CORS.
Otherwise, the iteration seems to work -> http://jsfiddle.net/gyTjL/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With