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

141
Views
Lista de publicaciones usando jquery ajax

tengo este codigo en razor

 @{ var aid = new List<int>(); foreach (var item in Model.applications) { if (item.Status == 1) { aid.Add(item.Id); } } }

y en js tengo esto:

 <script> function checkIfSigned() { var data = { aid: @aid }; console.log(data); $.ajax({ url: '@Url.Action("Method", "Controller")', type: "POST", data: data, ... }); }

y en mi controlador:

 public JsonResult Method(List<int> aid) { foreach (var item in aid) { ... } }

Mi problema es:

var datos = { ayuda: @aid };

Lanza una excepción:

SyntaxError no detectado: literal de plantilla no terminado

var datos = { ayuda: System.Collections.Generic.List`1[System.Int32] };

¿Que puedo hacer? ¿Cómo puedo publicar la lista?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puedes hacer así:

 var data = []; // javascript array @foreach(var item in Model.applications) { if (item.Status == 1) { <text> /* start JS */ data.push('@item.Id'); /* end JS */ </text> } }

y en JS Ajax:

 <script> function checkIfSigned() { console.log(data); $.ajax({ url: '@Url.Action("Method", "Controller")', type: "POST", data: data, ... }); } </script>
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!