Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
el mensaje se muestra indefinido cuando ajax publica en ASP.net

Hola, soy bastante nuevo en la codificación y en asp.net y se me ocurrió un error, por favor ayúdame si puedes. Esta es mi secuencia de comandos cuando ejecuto el código que se proporciona a continuación usando una función onclick, el mensaje de éxito se muestra como indefinido y la función C# SaveData que coloqué en el punto de interrupción no alcanza. Claramente, la publicación no llegó a la función del servidor.

texto1 y texto2 son dos variables

 $.ajax({ type: "post", contentType: "application/json; charset=utf-8", url: "Default.aspx/SaveData", data: "{dataval: '" + text1 + "', dataval1: '" + text2 + "'}", dataType: "json", success: function (data) { alert(data.d); }, });

lado del servidor

 [WebMethod] public static string SaveData(string dataval, string dataval1) { string data = String.Format("Your Name is {0} and address is {1}", dataval, dataval1); return data; }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

He creado esta muestra y funciona bien. Por favor, marque la respuesta a continuación.

 $.ajax({ type: "GET", url: "/Home/SaveData", data: { dataval: 'asd', dataval1: 'asd' }, dataType: "json", success: function (data) { debugger alert(data); }, }); });

back-end

 [HttpGet] public ActionResult SaveData(string dataval, string dataval1) { string data = String.Format("Your Name is {0} and address is {1}", dataval, dataval1); return Json(data, JsonRequestBehavior.AllowGet); }

Espero que esto te haya ayudado.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!