ajax+sucess+data,javascript - Ajax Success data returns complete HTML page - Stack Overflow

I'm using iFrame class JSP page with Date picker field on it. On selecting a date from the picker, I'm sending the date to the Struts Action using jQuery AJAX call like below:

$( "#datepickerStart" ).datepicker({

onSelect: function(dateText, instance) {//date select from picker to trigger

$.ajax({

type: "Post",// post method

url: 'checkAvailability.do?operation=getlist&datepickerStart='+ ("#datepickerStart").val(), // passing URL with date value to STRUTS Action

data: "date="+date,

//dataType: "application/json",

success: function(data) {

alert(data); //getting with the complete HTML page

}

});

}

});

And from DB I'm fetching the results in LIST and converting to JSON object like below:

Gson gson = new Gson();// Using google GSON to convert to JSON

String json = new Gson().toJson(lRList);

response.setContentType("application/json");// setting content type

response.setCharacterEncoding("UTF-8"); //setting character encoder

response.getWriter().write(json);// writing to response the JSON object

System.out.println("JSON Object::"+json);

And in standard output gives me the result like this:

JSON Object::[{"bookDate":"2014-07-11","fromTime":"2:00PM","totime":"3:30PM","userID":"XXX","isSuccess":false},

{"bookDate":"2014-07-11","fromTime":"10:30AM","totime":"11:00AM","userID":"XXX","isSuccess":false}]

But the alert in Ajax success gives the complete HTML page :(. I need this data and want to populate the values in the same JSP by showing in a div table. So can anyone help me on this to resolve it and let me know where I'm doing the mistake...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值