jQuery .ajax call returning undefined or null in the success function call
I have the following jQuery ajax call:
executeAllAjaxCalls:function() {
if (WALMART.jQuery.ajaxCalls.length) {
var dataPassed = "ajaxCalls="+WALMART.jQuery.ajaxCalls;
WALMART.jQuery.ajax({
url: WALMART.jQuery.ajaxFrameworkUrl
, data: dataPassed
, dataType: WALMART.jQuery.jsonResponseType
, type: 'POST'
, success: WALMART.jQuery.AjaxObject_Consolidated.processConsolidatedData
});
}
}
The data coming back in the function call upon success is undefined.
Here is the function called upon success of the ajax call:
processConsolidatedData:function(result) {
alert("1234"+result);
var responseData = eval('(' + result.responseText + ')');
if (typeof responseData !== '') {
for (resp in responseData) {
开发者_运维知识库 ALMART.jQuery(document).ready(responseData[resp].CallbackFunction);
}
}
}
Why is the response null or undefined when the struts action at the backend c:out a valid JSON object. Any tips or pointers appreciated as I am very new to jQuery.
I think there is an error in your code...
for (resp in responseData) {
ALMART.jQuery(document).ready(responseData[resp].CallbackFunction);
}
I think you ment:
for (resp in responseData) {
WALMART.jQuery(document).ready(responseData[resp].CallbackFunction);
}
I would also use jQuery.parseJSON instead of 'eval', unless necessary.
精彩评论