0

I have an actionURL in my jsp from which I am calling a method called "updateDB" in my java file. whenever I submit the form through an AJAX request using A.io.request , this udpateDB function in my java code is being called, where I am doing some database CRUD operations.

I want to know how can I send some values(either success/failure status of database insertion) back to my jsp from java code to the success callback of my A.io.request ajax call.

You can find below my Ajax request :

Liferay.provide(window,‘submitForm’,
function() {
var A = AUI();
A.io.request(‘${”formsubmissionURL”}’,{
method: ‘POST’,
form: { id: ‘<portlet:namespace />fm’ },
on: {
success: function(){
alert(form submitted”);

// I WANT DATABASE SUCCESS OR FAILURE STATUS HERE FROM JAVA CODE
     }
   }
  });
});

Thanks

Kiran Kulkarni
  • 1,434
  • 2
  • 18
  • 40

1 Answers1

0

You can pass data values by writing it to resourceResponse.

response.getWriter().write(String/int/char[])

Here, response can be servletResponse or portletResponse(resourceResponse)

You can get data in javascript like

this.get('responseData') inside success method.

EDIT: As you are calling action method via ajax call, below code may be helpful.

PortalUtil.getHttpServletResponse(actionResponse)

Get httpServletResponse from code above and then you can use response.getWriter().write method.

Pankaj Kathiriya
  • 4,210
  • 2
  • 19
  • 26