0

I'm trying to call JSF controller method using jquery ajax But I'm getting 404 error. Please help. getTest() jsf method returning string .

$.ajax({
   url: '/SpaceDataController/getTest',
   type: 'GET',
   dataType: 'json',
   success: function () {
      alert("success");
   },
   error: function () {
      alert('error');
   }
});
  • Since we dont see your jfs code we can't tell. Since 404 means your client cant communicate with the server, I think you may be calling the jsf function the wrong way here. Take a look at the followings : http://stackoverflow.com/questions/9619906/calling-managed-bean-method-from-javascript and http://stackoverflow.com/questions/23920198/call-a-jsf-method-via-js – Jason Krs Jan 03 '17 at 07:07
  • I dont want to use jsf ajax. Is it possible to call JSF controller using jquery ajax? thnks:) – AshiWandre Jan 03 '17 at 07:36
  • Sorry. Maybe I provided incomplete information. Visit the link suggested on top of your OP. I has a more comprehensive answer to your question. Btw always try to google your questions in stackoverflow to see if an answer already exist – Jason Krs Jan 03 '17 at 11:44
  • @Balusc I'm referring this https://www.linkedin.com/pulse/jsf-ajax-moving-xhr-calls-from-jquery-native-js-sathyakumar. please go through this one. I am able to hit the JSF controller but I didn't get success response even after returning "test" string. What should I do now, please help. Thanks – AshiWandre Jan 03 '17 at 11:49
  • All due respect, that article is BS. Just use the right framework/API for the purpose as explained in duplicate instead of abusing JSF framework for purposes it was never designed for. – BalusC Jan 03 '17 at 11:52
  • @BalusC Okay. Thanks for your valuable guidance. I will post if anything needed for same. – AshiWandre Jan 04 '17 at 06:11

0 Answers0