Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET jQuery
I have the Jquery part for call the web method in c#
 
<script type="text/javascript">
$(document).ready(function () {
$('#btnLoadUserCtrl').click(function () {
var ControlName = "~/sample.ascx";
alert(ControlName);
$.ajax({
type: "POST",
url: "sample.aspx/Result",
data: "{controlName:'" + ControlName + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response);
$('#uControl').html(response);
},
failure: function (msg) {
alert("msasdas");
alert(msg);
$('#uControl').html(msg);
}
});
});
});
</script>
 
In this webMethod that returns the string value , After the excecution of function, it came to the success section of jquery, but returns null value..
Posted 7-Nov-12 1:00am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can try like this:
success: function (response) {
var result = response.d;
//if webmethod returning any list 
for (var i = 0; i < result.length; i++) {
  alert(result[i].Property_Name);
}
//Or 
alert(result );
}
  Permalink  
Comments
Member 8393790 at 8-Nov-12 1:10am
   
thank u for ur reply
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

in your success function just put response.d instead of response
Like
alert(response.d)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 547
1 ChauhanAjay 180
2 CHill60 135
3 Maciej Los 125
4 Richard Deeming 125
0 Sergey Alexandrovich Kryukov 9,735
1 OriginalGriff 6,987
2 CPallini 5,835
3 George Jonsson 4,017
4 Gihan Liyanage 3,266


Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100