留言板
Ajax functions calls onSubmit
Hi,
This is my view.jsp
<aui:form name="fm" method="POST" action="<%= updateArticleURL.toString() %>" enctype="multipart/form-data"
onSubmit='<%= "event.preventDefault(); " + renderResponse.getNamespace() + "warn();" %>'>
/* Form Fields and Inputs */
<aui:button-row>
<aui:button name="saveButton" type="submit" value="Save" />
<a href="<portlet:renderURL/>">
<aui:button name="cancelButton" type="cancel" value="Cancel" /></a>
</aui:button-row>
</aui:layout>
</aui:form>
<aui:script>
function <portlet:namespace />warn(){
submitForm(document.<portlet:namespace />fm);
<portlet:namespace/>submit();
}
function <portlet:namespace/>submit(){
AUI().use('aui-base','aui-io-request','aui-node', function(A){
A.io.request('<%=resourcURL%>',
{
on: {
success: function() {
alert(this.get('responseData'));
}
}
});
});
}
</aui:script>
In this ajax script ,
I have submit the form using ajax function (<portlet:namespace/>warn()) after that I want to retrieve the response data from the server corresponding to the <portlet:namespace/>submit() ajax function for the fileEntryId of the current submitForm ajax
But I retrieve the response data for the previous submit form and after that (<portlet:namespace/>warn()) function works.
Do I make any mistakes ? or please let me know the correct solution
Thank You,
Madasamy
This is my view.jsp
<aui:form name="fm" method="POST" action="<%= updateArticleURL.toString() %>" enctype="multipart/form-data"
onSubmit='<%= "event.preventDefault(); " + renderResponse.getNamespace() + "warn();" %>'>
/* Form Fields and Inputs */
<aui:button-row>
<aui:button name="saveButton" type="submit" value="Save" />
<a href="<portlet:renderURL/>">
<aui:button name="cancelButton" type="cancel" value="Cancel" /></a>
</aui:button-row>
</aui:layout>
</aui:form>
<aui:script>
function <portlet:namespace />warn(){
submitForm(document.<portlet:namespace />fm);
<portlet:namespace/>submit();
}
function <portlet:namespace/>submit(){
AUI().use('aui-base','aui-io-request','aui-node', function(A){
A.io.request('<%=resourcURL%>',
{
on: {
success: function() {
alert(this.get('responseData'));
}
}
});
});
}
</aui:script>
In this ajax script ,
I have submit the form using ajax function (<portlet:namespace/>warn()) after that I want to retrieve the response data from the server corresponding to the <portlet:namespace/>submit() ajax function for the fileEntryId of the current submitForm ajax
But I retrieve the response data for the previous submit form and after that (<portlet:namespace/>warn()) function works.
Do I make any mistakes ? or please let me know the correct solution
Thank You,
Madasamy
David H Nebinger,修改在7 年前。
RE: Ajax functions calls onSubmit
Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
Two completely different things.
Form submit is a regular action/response cycle where there is no ajax interaction.
Ajax would be done using a resource request.
You can't mix the two willy nilly and think things are going to work the way you want.
Form submit is a regular action/response cycle where there is no ajax interaction.
Ajax would be done using a resource request.
You can't mix the two willy nilly and think things are going to work the way you want.
David H Nebinger:
Two completely different things.
Form submit is a regular action/response cycle where there is no ajax interaction.
Ajax would be done using a resource request.
You can't mix the two willy nilly and think things are going to work the way you want.
Thank You for your reply David
Have any other possible solution to achieve these two things on the same button??