r3plica
01-09-2012, 07:49 AM
This is doing my nut in.
I have this simple jquery code in my app:
<script type="text/javascript">
$(document).ready(function () {
var items = @ViewData["items"];
$.each(items, function() {
$.each(this, function(index, item) {
alert(item);
});
});
});
</script>
If I view this in FireBug the variable "items" looks like this:
var items = [{"ImagePath":"44610855-36b9-438d-8b26-23fa96509413.jpg"},{"ImagePath":"bdf0a07d-f20c-4999-a044-43f7111338dd.jpg"},{"ImagePath":"51aa8f86-b352-47ea-a835-8a90f5833db2.jpg"},{"ImagePath":"6aabe090-5e78-4751-ac79-9f37a65dd776.jpg"}];
now, I did a replace on " to a random string (I used moo) and it didnt work, but when i did a replace on " it did. So that tells me that I am actually returning a valid Json string.
However, the code just doesn't work.
I can't see the wood for the trees, so any help would be greatly appreciated.
I have this simple jquery code in my app:
<script type="text/javascript">
$(document).ready(function () {
var items = @ViewData["items"];
$.each(items, function() {
$.each(this, function(index, item) {
alert(item);
});
});
});
</script>
If I view this in FireBug the variable "items" looks like this:
var items = [{"ImagePath":"44610855-36b9-438d-8b26-23fa96509413.jpg"},{"ImagePath":"bdf0a07d-f20c-4999-a044-43f7111338dd.jpg"},{"ImagePath":"51aa8f86-b352-47ea-a835-8a90f5833db2.jpg"},{"ImagePath":"6aabe090-5e78-4751-ac79-9f37a65dd776.jpg"}];
now, I did a replace on " to a random string (I used moo) and it didnt work, but when i did a replace on " it did. So that tells me that I am actually returning a valid Json string.
However, the code just doesn't work.
I can't see the wood for the trees, so any help would be greatly appreciated.