json - jQuery ajax request from asmx web service -
i'm attempting request data http post asmx web service jquery's ajax. i've read numerous guides on how correctly no success. can determine, request failing:
$.ajax({ type: 'post', url: "http://data.niassembly.gov.uk/organisations.asmx/getpartieslistcurrent_json", contenttype: 'application/json; charset=utf-8', data: json.stringify({}), datatype: 'json', success: function(data){ if (data.hasownproperty('d')){ msg = data.d; } else { msg = data; } alert(msg); } , error:function(){ alert('error'); } }); the json formatting correct , when save content local .json file function works. service has option i've read won't work in case.
try this:
$.ajax({ type: 'post', //url: "http://data.niassembly.gov.uk/organisations.asmx/getpartieslistcurrent_json", url: "http://data.niassembly.gov.uk/organisations_json.ashx?m=getpartieslistcurrent", contenttype: 'application/json; charset=utf-8', data: json.stringify({}), datatype: 'jsonp', success: function(data) { alert(data.organisationslist.organisation[1].organisationname); }, error: function() { alert('error'); } }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Comments
Post a Comment