Fórum

Success function not working in ajax

Madasamy P, modificado 7 Anos atrás.

Success function not working in ajax

Junior Member Postagens: 90 Data de Entrada: 27/07/16 Postagens Recentes
I have an form which has 3 file Fields

<aui:form name="fm" id="fm" enctype="multipart/form-data">
<aui:column columnWidth="33" first="true">
<input type="file" name="articleFile" id="new_Btn1" multiple="true"
onchange="submitForm()" />
</aui:column>
<aui:column columnWidth="34">
<input type="file" name="artFiles" multiple="true" id="new_Btn2"
onchange="submitForm()" />
</aui:column>
<aui:column columnWidth="33" last="true">
<input type="file" name="supportFiles" multiple="true" id="new_Btn3"
onchange="submitForm()" />
</aui:column>
</aui:form>

<aui:script>
function submitForm(){
AUI().use('aui-base','aui-io-request',function(emoticon{
//alert("file uploaded");

B.io.request('<%=resourcURL.toString()%>',
{
dataType: 'json',
method: 'GET',
form: {
id:'<portlet:namespace/>fm',
upload:true
},
on: {
success: function() {
alert("uploaded");
}
}
});
});
}
</aui:script>



When I'm using
upload:true in ajax request, the success function (alert message) not works
Otherwise success function works but the files not passed to servlet through ajax request
thumbnail
Naresh Reddy Kallamadi, modificado 6 Anos atrás.

RE: Success function not working in ajax

Regular Member Postagens: 120 Data de Entrada: 09/07/14 Postagens Recentes
Hi Madasamy,

I too facing same issue, Have you found any solution?

Thanks,
naresh Kallamadi.
thumbnail
Naresh Reddy Kallamadi, modificado 6 Anos atrás.

RE: Success function not working in ajax

Regular Member Postagens: 120 Data de Entrada: 09/07/14 Postagens Recentes
Hi Madasamy,

When we are using ajax for form uploads success method won't be execute. write success logic in complete method:
complete: function(data) {
alert("this is from alert complete "+data);
jQuery.each(data, function(index, value) {
alert("id "+value.id);
alert("id "+value.name);

});
}

Thanks,
Naresh Kallamadi.