Tengo este codigo de un tutorial que estoy aprendiendo
Código HTML:
<html> <head> <link href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script> </head> <body> <script type="text/javascript"> /* <![CDATA[ */ (function($) { $.fn.changeType = function(){ var data = [ { "department": "IT", "jobs": [ {"title":"Programmer"}, {"title":"Solutions Architect"}, {"title":"Database Developer"} ] }, {"department": "Accounting", "jobs": [ {"title":"Accountant"}, {"title":"Payroll Officer"}, {"title":"Accounts Clerk"}, {"title":"Analyst"}, {"title":"Financial Controller"} ] }, { "department": "HR", "jobs": [ {"title":"Recruitment Consultant"}, {"title":"Change Management"}, {"title":"Industrial Relations"} ] }, { "department": "Marketing", "jobs": [ {"title":"Market Researcher"}, {"title":"Marketing Manager"}, {"title":"Marketing Co-ordinator"} ] } ] var options_departments = '<option>Select<\/option>'; $.each(data, function(i,d){ options_departments += '<option value="' + d.department + '">' + d.department + '<\/option>'; }); $("select#departments", this).html(options_departments); }; })(jQuery); $(document).ready(function() { $("form#search").changeType(); }); /* ]]> */ </script> <form id="search" action="" name="search"> <select name="departments" id="departments"> <option>Select</option> </select> </form> </body> </html>
Código:
Gracias por todo $.getJSON('http://dominio.com/archivo.json'