0
Below is my "form" I want to send to the server in an ajax post
$('#ajaxButton').on('click', function () {
const ajaxFormData = {
nome: $('#nome').val(),
zap: $('#whatsapp').val(),
email: $('#email').val()
};
$.ajax({
url: "/plano-detalhes.aspx",
data: ajaxFormData,
type: "POST",
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="ajaxForm">
<h2>Negociar Valores</h2>
<label>
Nome
<input id="nome" type="text"/>
</label>
<label>
Whatsapp
<input id="whatsapp" type="text" />
</label>
<label>
e-mail
<input id="email" type="text"/>
</label>
<button id="ajaxButton">Enviar</button>
</div>
The problem is that I don’t know how to collect this data sent on the aspx page, see what I’m trying below:
Request r = new Request();
if (r.isPost)
{
try
{
dictionary<string, string> ajaxData = new Dictionary<string, string>();
foreach(KeyValuePair<string, string> n in r.data)
{
ajaxData.Add(n.Key, n.Value);
}
//apenas para eu tentar ler
System.Diagnostics.Debug.Write(ajaxData.toString());
}
catch(Exeption e)
{
System.Diagnostics.Debug.Write(e);
}
}
I’m new in C# ASP.NET, I came from a javascript background, I couldn’t find any way to read the data I’m sending.
thank you in advance
What are you using? webforms or mvc?
– Aesir
webforms, and in this case I can not send directly through the normal form, if not from the refresh on the page and, I’m picking up some data from the previous page.
– MSHijo