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

160
Visualizações
How to read ajax success response

c# code

   string temp3 = dt.ToString();

            cmd.Connection = con;
            con.Open();
            i = cmd.ExecuteNonQuery();
            con.Close();

            if (i == 1)
            {
                msg = "Record Sucessfuly inserted";
            }
            else
            {
                msg = "Error";
            }
           
            //ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + msg + "')", true);
        }
    }
    else
    {
        msg="MCQ";
    }

j-query code

     $.ajax({
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    url: "AddQuestions.aspx/SaveClickFunc",
                    data: "{ 'questionData': '" + JSON.stringify(obj) + "' }", 
                    
                    success: function (response) {
                        console.log(response);
                        
                        
                        if (response == "MCQ") {
                            console.log("MCQ");
                            alert('You can not enter more than' + $("#MCQ").text()+' MCQ Questions');
                            
                        }
                        else if (response == "SUBJ") {
                            console.log("SUBJ");
                            alert('You can not enter any more Subjective Questions');
                        }
                    },

                });

I first send data from aspx page using ajax and after that return a msg after completing c# function I am not getting any alert and if i try alert(response) it returns "[object][object]"

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

the answers is so simple just replace

    (response == "MCQ") 

by

    (response.d == "MCQ")
about 4 years ago · Santiago Gelvez 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