Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

84
Visualizações
Is it possible to update only one property of a model using AJAX?

I have a model, JobApplicationForm. This model is split into a short app and a long app. Meaning the 1st page posts certain attributes to the model, and once the last 3 pages are finished another post updates the model to be completely filled out.

public class JobApplicationForm
{
    public int Prop1 {get; set}
    public string Prop2 {get; set;}
    public string Prop3 {get; set;}
    public string Prop4 {get; set;}
    public string Prop5 {get; set;}
    public int CompletionStatus {get; set;} 
}

In the 1st Post action, the model fills Prop1 and Prop2, and sets CompletionStatus = 1. This is a post after 1 page of the form is completed.

Then in the 2nd Post action, there are 3 more pages that fill in Prop 3, 4, 5, and sets CompletionStatus = 4 when the final page is submittmed.

Since the 2nd part of the form is 3 pages that come together. Is there a way to use AJAX to simply update completionStatus to 2 and 3 on their respective pages? When trying to post using AJAX I have found online that the model has to be fully filled out, and am unable to find anyone just updating one property. I am not trying to update the view at all when changing completionStatus, just simply trying to update the model's property.

Ajax(status is an int variable defined elsewhere)

    $('.next.button').click(function() {
    $.post('/Home/UpdateCompletionStatus', {completionStatus : status});
});

3rd Controller I created to update this one property.

[HttpPost]
public ActionResult UpdateCompletionStatus([FromBody]JobApplicationForm model, int status)
{
    if (ModelState.IsValid)
    {
        model.CompletionStatus = status;
    }
    return new EmptyResult();
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I solved my own problem. The reason it wasn't updating was because the model binding is confused. I called the paramater status in the controller but then in the ajax called it completionStatus.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda