codigo c#
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"; }código j-query
$.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'); } }, });Primero envío datos desde la página aspx usando ajax y luego devuelvo un mensaje después de completar la función c #. No recibo ninguna alerta y si intento alertar (respuesta) devuelve "[objeto] [objeto]"
las respuestas son tan simples solo reemplaza
(response == "MCQ")por
(response.d == "MCQ")