$.ajax({
type: "POST",
url: "Default2.aspx/myMethod",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function OnSuccess(response) {
var str = response.d;
var jsonObj = JSON.parse(str);
for(i=0;i<jsonObj.length;i++)
{
jsonObj[i]="{"+jsonObj[i]+"}"
}
jsonObj = "[" + jsonObj + "]";
},
failure: function (response) {
alert(response.d);
}
});
What I recevied in jsonObj is the javascript array of images path. I pass this array to a image slider to show images but it shows undefined i.e not displayed the images the result of jsonObj is
[{'src: ../img/kota-image/11.jpg'},{'src: ../img/kota-image/12.jpg'},{'src: ../img/kota-image/13.jpg'},{'src: ../img/kota-image/14.jpg'},{'src: ../img/kota-image/15.jpg'},{'src: ../img/kota-image/197.jpg'},{'src: ../img/kota-image/2706.jpg'},{'src: ../img/kota-image/9.jpg'},{'src: ../img/kota-image/DSC_0825.JPG'},{'src: ../img/kota-image/kota.jpg'}]
my image slider is
jR3DCarousel = $('.jR3DCarouselGallery').jR3DCarousel({
width: $(window).width(), /* largest allowed width */
height: 670, /* largest allowed height */
slides: jsonObj/* array of images source */,
"animationDuration": 1500,
"animationInterval": 2500,
});
{'src: ../img/kota-image/12.jpg'}is not valid javascript.JSON.stringify()to turn it into JSON if you need.