I have a code snippet where I am hittting a Servlet with POST request, the servlet is returning the correct response but in my code I am getting that response object as NULL. The code snippet is below :
CQ.shared.HTTP.post('/bin/services/damwhitelistcheck', function(options, success, tzOffset, response) { if(success) { var jsonResponse = CQ.shared.HTTP.eval(response); } }, {filePath: fileUploadLocation,extension: extension}, this, true, true);
This behaviour is also observed in many places wherever I am trying to implement things like this. I am not sure why response object comes as NULL because when I see in firebug response is coming correct. Can anyone help me on this?
Solved! Go to Solution.
Views
Replies
Total Likes
In the past i have used succesfully a jquery AJAX request to post data to the Sling Servlet, as shown in the following link.
http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Views
Replies
Total Likes
In the past i have used succesfully a jquery AJAX request to post data to the Sling Servlet, as shown in the following link.
http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Views
Replies
Total Likes
I think response should be captured at http.post level like
var resp = CQ.shared.HTTP.post('/bin/services/damwhitelistcheck',
Views
Replies
Total Likes
Ultimately solved that using a different way making an ajax call
var url = CQ.HTTP.noCaching("/bin/services/myservlet"); url = CQ.HTTP.addParameter(url, "filePath", fileUploadLocation); url = CQ.HTTP.addParameter(url, "extension", extension); var response = CQ.HTTP.get(url); var allowed = false; if (CQ.HTTP.isOk(response)) { var data = CQ.Util.eval(response); allowed = data.Allowed; if(allowed == "false"){ alert("allowed is false"); } }
Here I am passing the arguments to the url using the addParameter method. And everything is working fine using this way.
Views
Replies
Total Likes
Views
Likes
Replies