hi all,
need little help with this issue - my sling servlet is working correctly on local but throwing blocked error on rde.
my local is also an SDK with same version as rde hence should not have been an issue.
my sling servlet is capturing data from couple of fields and sending it to servlet.
the ajax call is written as below -
$.ajax({
type: "GET",
url: "/bin/ACL/lookup.json",
data: {
cgn: cgn.toString(),
cgi: cgi.toString(),
name: name
},
success: function(resp) {
console.log("Response is " + JSON.stringify(resp));
location.reload(true);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus);
alert("Error: " + errorThrown);
}
});
the data object is valid and forming correctly. the success function is not executing ofcourse and the error function is just displaying pop up with Status: Error
the servlet is registered by path and in the logs there are loggers for the get method but they are not being logged on rde.
Solved! Go to Solution.
Views
Replies
Total Likes
Try removing the <form> tag if present or add event.preventDefault() on the click of submit button. This will ensure that the form submit action and ajax URL redirection do not conflict with each other.
NS_BINDING_ABORTED error is suggestive of ajax's URL and form submit's action both running and cancelling ajax request action.
It's probably because your local AEM runs on localhost:4502, and your rapid development environment runs on localhost:8080. Take a look at the network tab, and it is probably a CORS error. Take a look at the network tab, what do you see?
You need to configure your Configure Apache Sling Referrer Filter to allow all hosts names.
The Apache Sling Referrer Filter is a security feature that helps prevent Cross-Site Request Forgery (CSRF) attacks by checking the HTTP Referer header of incoming requests. When the filter is active, it ensures that requests to AEM's localhost:4502 only come from trusted sources (e.g., the AEM site itself) and not from unauthorized external domains.
If your local:8080 needs to make AJAX requests to the AEM environment running on localhost:4502, the Referrer Filter might block those requests, resulting in CORS issues.
Although this tutorial mentioned about how to enable "POST" from postman to your local AEM environment, I think it should give you more insight on how to setup the referrer filter, https://sourcedcode.com/blog/aem/how-to-make-simple-http-post-methods-in-aem-with-a-http-rest-client
@BrianKasingli- the RDE doesn't run on my localhost:8080 - It is a dedicated environment on the cloud and has program id as well as environment id. I am deploying the servlet via code and in the configuration json it is present in the project bundle. the servlet should run irrespective of the environment as we are not sending request from 8080 to 4502.
Can you share your request headers?
A screenshot from the Network tab will help.
the request headers are empty as well as response headers. on Firefox the request is shown as aborted while on chrome the request is shown as blocked.
Is there any subsequent call in network trace post the servlet call? Or the page getting refreshed post the servlet execution?
One of the reasons I can think of is trigger of another request before the servlet request could complete. A screenshot of the network trace will help in this case.
there's a call to the same page occurring with query params which is getting 200 ok and always following the servlet call.
on firefox the call is getting aborted by ns binding aborted error, this is due to another req aborting the first req. How can I resolve this?
Try removing the <form> tag if present or add event.preventDefault() on the click of submit button. This will ensure that the form submit action and ajax URL redirection do not conflict with each other.
NS_BINDING_ABORTED error is suggestive of ajax's URL and form submit's action both running and cancelling ajax request action.
event.preventDefault() worked for me
@aem_noob We hope you found the AEM community valuable. We anticipate your return as either a learner or a contributor. The community benefits from SMEs like you. Please ask your AEM peers to join and contribute. Happy AEM learning!
Views
Replies
Total Likes
@aem_noob can you post the error you are seeing in the browser console? Did you check if the Servlet was successfully installed/resolved? did you try to call it from Postman or any other external source?
the servlet was successfully resolved yes. We are calling it from our local machine to validate its working fine. It is on RDE the issue is present.
Views
Likes
Replies
Views
Likes
Replies