Simple Jquery getJSON Example

avnish
avnish
Participant
242 Points
11 Posts

Please Correct It...................................

$(document).ready(function () {
$("button").click(function () {
    $.getJSON('CommonAjaxAdd.aspx', getvalue);
  });
});
function getvalue(r) {
$("#para1").text(r);
}

C# code............................

Response.Clear(); 
Response.Write("Avnish");
Response.End();
Views: 8764
Total Answered: 4
Total Marked As Answer: 2
Posted On: 17-May-2015 02:16

Share:   fb twitter linkedin
Answers
Brian
Brian
Moderator
2232 Points
14 Posts
         

Hi Avnish,

I think $.getJSON() method is use for json response.In your case use $.get() method as:

$(document).ready(
function () {
$("button").click(function () {
$.get('CommonAjaxAdd.aspx', getvalue);
});
});

 

Posted On: 17-May-2015 04:46
avnish
avnish
Participant
242 Points
11 Posts
         

please give me json response code

I mean C# code for json response

Posted On: 17-May-2015 03:02
Brian
Brian
Moderator
2232 Points
14 Posts
         

Hi Avnish,

JSon Response like:

 
Response.Clear();
Response.Write("\"avnish\"");
Response.End();
 

 

Posted On: 17-May-2015 05:52
avnish
avnish
Participant
242 Points
11 Posts
         

thanku very much.....laughing

Posted On: 17-May-2015 05:17
 Log In to Chat