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

157
Views
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 answers
Answer question

0

the answers is so simple just replace

    (response == "MCQ") 

by

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