jquery 양식을 서블릿에 사용하고 있습니다. xyz 값을 서블릿에 보냅니다. xyz에 알맞은 값을 표시하지만 콜백 함수의 데이터 경고는 null
으로 표시됩니다. 여기 내 스크립트 여기jquery 양식 서블릿 제출
<script>
$(document).ready(function(){
$("#country_id").change(function() {
var xyz = $("option:selected").val();
alert(xyz)
// var url ="../Retrive_country?stateadd_1=none&countryREF="+xyz;
$.get("../Retrive_country?stateadd_1=none",
{countryref : xyz } ,function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
//$(location).attr('href',url);
});
});
</script>
이다 내가 잘못
String countryref= request.getParameter("countryREF");
String sql1 = "SELECT * FROM state WHERE country_ref="+countryref+" ";
PreparedStatement pst1 = db.getConnection().prepareStatement(sql1);
ResultSet j = pst1.executeQuery();
while (j.next()) {
String state_id = j.getString(1);
state = j.getString(2);
country_ref = j.getString(3);
location.setState(state);
location.setState_id(state_id);
location.setcountry_ref(country_ref);
}
pw.println(countryref);
를하고있는 중이 야 .. 내 JSP 여기
<html>
<body>
<div class="span2 clear">
<select name="country_id" id="country_id">
<option>-select-</option>
<option value="1" id="blabbb">1</option>
<option value="2" id="blabbb">2</option>
<option value="3" id="blabbb">3</option>
</select></div>
</body>
</html>
내 서블릿은 무엇?
$(document).ready(function() {
$("#country_id").change(function() {
var xyz = $("option:selected").val();
$.get("../Retrive_country?stateadd_1=none", {
countryref: xyz
})
.done(function (data) {
alert("Data Loaded: " + data);
});
});
});
OR :
thanx jjenzz thi works nw. – 3bu1