0
I’m trying to make a Post of a form info but I don’t quite know how to do.
This is my C form# :
@using (Html.BeginForm("Enviar", "Mensagem", FormMethod.Post, new { enctype = "multipart/form-data", @class = "", @id = "formNovaMsg" }))
{
<div class="">
<div style="display: none;">
<input id="LojaId" name="LojaId" value="@Model.LojaId" />
</div>
<div style="display: none;">
<input id="ClienteId" name="ClienteId" value="@Model.Mensagens[0].ClienteId" />
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="input-group">
<input type="text" id="Conteudo" name="Conteudo" placeholder="Escreva sua mensagem ..." class="form-control">
<span class="input-group-btn">
<button type="submit" id="btnSubmit" class="btn btn-warning btn-flat">Enviar</button>
</span>
</div>
</div>
<!-- /.box-footer-->
</div>
}
To be able to give the post I followed an example that resulted in the following function:
$("#formNovaMsg").ajaxForm({
type: "post",
beforeSubmit: function (arr, $form, options) {
loading();
},
success: function (data) {
if(!data.Erro){
$("#conversa").append(data.Html);
$("#formNovaMsg")[0].reset();
$(".msgsis").fadeOut(300);
var elem = document.getElementById('conversa');
elem.scrollTop = elem.scrollHeight;
}
}
});
This view is a kind of chat the idea and it send the message and already give the post direct.
When I’m trying this way I’m trying it wrong Uncaught TypeError: $(...).ajax is not a function
i checked the Jquery and are not conflicting ( I have only 1 , 1.9.1).
ah intendi , but in the case then I take that Begin Form and leave only one html form even ?
– William Cézar
Yeah. Try it on and let me know if it works ^^
– Marco Giovanni
I’m gonna test it now, but still vlw ai cara.
– William Cézar
I think it worked , but with your example I managed to intender a lot, I’m following an example that uses Viewenginer , but ta returning null, but this problem worked , anything I return with another question, thanks.
– William Cézar