Note that there are some explanatory texts on larger screens.

plurals
  1. POajax call not sending data
    text
    copied!<p>I'm using ajax call but I don't get any answer. In the next image you can see that the call works correctly but i don't get a data. <img src="https://i.stack.imgur.com/jPGmh.png" alt="enter image description here"></p> <p>My html is the next code: </p> <pre><code>&lt;script&gt; // wait for the DOM to be loaded $(document).ready(function() { // bind 'myForm' and provide a simple callback function $('#form input').on('change', function() { var valueSelected = $("#form").find('input:checked').val(); /*$.post("http://localhost:49918/Home/HandleForm", {howGood : valueSelected}, function(respuesta) { console.log("La respuesta es:", respuesta) });*/ $.ajax({ type: "POST", url: "http://localhost:49918/Home/HandleForm", data: { howGood : valueSelected }, success: function(respuesta){ console.log("La respuesta es:", respuesta) }, error: function(respuesta){ console.log("Fail:", respuesta) } }); }); }); &lt;/script&gt; &lt;div class="content-area"&gt; &lt;h1&gt;How Good Are You&lt;/h1&gt; &lt;form name="form" id="form" method="post"&gt; &lt;input type="radio" name="howGood" value="Excellent"&gt;Excellent&lt;br&gt; &lt;input type="radio" name="howGood" value="VeryGood"&gt;Very Good&lt;br&gt; &lt;input type="radio" name="howGood" value="Good"&gt;Good&lt;br&gt; &lt;input type="radio" name="howGood" value="Average"&gt;Average&lt;br&gt; &lt;input type="radio" name="howGood" value="Poor"&gt;Poor &lt;br&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>and my code in the server is(It works perfctly, I can debbug successly): </p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web.Services; namespace MvcApplication3.Controllers { [HandleError] public class HomeController : Controller { public ActionResult Index() { return View(); } [WebMethod] public string HandleForm() { string howGood = null; try { howGood = Request.Form["howGood"]; string connectionString = ConfigurationManager.ConnectionStrings["indivirtualTest"].ConnectionString; SqlDataAdapter SqlDataAdapter = new SqlDataAdapter(); SqlCommand SqlCommand = new SqlCommand(); SqlConnection conection = new SqlConnection(connectionString); conection.Open(); string query = "UPDATE Howgoodareyou SET " + howGood + " = " + howGood + " + 1"; SqlCommand myCom = new SqlCommand(query, conection); myCom.ExecuteNonQuery(); // SqlDataReader dr = SqlCommand.ExecuteReader(CommandBehavior.CloseConnection); conection.Close(); } catch (Exception e) { throw e; } return howGood; } } } </code></pre> <p>Can someone help me? I don't get any answer.... but the code is execute correctly. </p> <p>Thank you, </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload