Hi,
I'm writing a simple code to show the weather of a US state and a related city but when I click on the button I doesn't work, can anyone help me and show me the right syntax and also the reason that why this happens?
my code is as below:
JQUERY$(document).ready(function () {$('#btn').click(function () {
var state = $('#ddl_states option:selected').text();
var city = $('#ddl_cities option:selected').text();
alert(state + city);$.ajax({
url: "http://api.wunderground.com/api/b5579d1a73a33985/conditions/q/" + state + "/" + city + ".json",
dataType: "jsonp",
success: function (item) {
console.log(item);
var html = "";
html += "<article><p>" + item.current_observation.feelslike_string + "</p>";
html += "<img src='" + item.current_observation.icon_url + "' alt='' </img>";
html += "</article>";$("#weatherdiv").append(html);
}
});
});
});HTML<body><form id="form1" runat="server"><asp:DropDownList ID="ddl_states" runat="server" DataSourceID="DS1" DataTextField="state" DataValueField="state_id"></asp:DropDownList><asp:SqlDataSource runat="server" ID="DS1" ConnectionString="<%$ ConnectionStrings: statesCS %>"
SelectCommand="select [state], [state_id] from [states]"></asp:SqlDataSource><asp:DropDownList ID="ddl_cities" runat="server" DataSourceID="DS2" DataTextField="city" DataValueField="city"></asp:DropDownList><asp:SqlDataSource runat="server" ID="DS2" ConnectionString="<%$ ConnectionStrings: statesCS %>"
SelectCommand="select state, city from cities where state=@state order by city"><SelectParameters><asp:ControlParameter Name="state" ControlID="ddl_states" /></SelectParameters></asp:SqlDataSource><button id="btn">Get weather</button><div id="weatherdiv"></div></form></body>Thanks in advance :)