Reputation: 1765
I have an ajax
call which will return a set<E>
. I need to process this set
from the JavaScript function from which I call this ajax.
<script type="text/javascript">
function mySr(id){
$.ajax({
type: 'POST',
url: '../controller/action',
data: 'id=' + id,
success: function(data) {
var length= data.length
var size = data.size
alert(data[0]+'----'+length+'--'+size+'----'+data)
},
error: function () {
alert('error')
}
});
</script>
This is the way i used,
The alert will display like this
["37", "40","80","90"]----22--undefined----[
I understood the data is clearly reached in the script but i don't know how to iterate through it.
How to iterate here?
How to get the length?
How to get each elements?
Upvotes: 0
Views: 69
Reputation: 120506
You need to parse the data
. Try putting data = $.parseJSON(data);
after the line success: function(data) {
See http://api.jquery.com/jQuery.parseJSON/ for more details.
Upvotes: 1