I have the following code, for passing a parameter to a web method, and retrieving a the result in jquery ajax:
<script type="text/javascript">
$(document).ready(function () {
$('#<%=btnSignup.ClientID %>').click(function () {
var dataString = JSON.stringify({
firstName: $("#SignupFirstName").val(),
lastName: $("#SignupLastName").val(),
email: $("#SignupEmail").val(),
password: $("#SignupPassword").val()
});
$.getJSON('Signup.aspx/Signup', function (data) {
});
$.ajax({
type: "POST",
url: "Signup.aspx/Signup",
data: dataString,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
beforeSend: function () {
// some code
},
success: function (result) {
$('#loading').hide();
if (result.hasOwnProperty("d")) { result = result.d; }//and some more code
}
});
return false;
});
});
</script>
and the web method:
[WebMethod]
public static SignupOutput Signup(string firstName, string lastName, string email, string password)
{
// execute some code and return an object for the json
}
The method is not executing, I'm using nice urls. Please help, if possible with code or examples.
get data with json in template
Hi.
I have the following code, for passing a parameter to a web method, and retrieving a the result in jquery ajax:
<script type="text/javascript"> $(document).ready(function () { $('#<%=btnSignup.ClientID %>').click(function () { var dataString = JSON.stringify({ firstName: $("#SignupFirstName").val(), lastName: $("#SignupLastName").val(), email: $("#SignupEmail").val(), password: $("#SignupPassword").val() }); $.getJSON('Signup.aspx/Signup', function (data) { }); $.ajax({ type: "POST", url: "Signup.aspx/Signup", data: dataString, contentType: "application/json; charset=utf-8", dataType: "json", async: true, cache: false, beforeSend: function () { // some code }, success: function (result) { $('#loading').hide(); if (result.hasOwnProperty("d")) { result = result.d; }//and some more code } }); return false; }); }); </script>
and the web method:
The method is not executing, I'm using nice urls. Please help, if possible with code or examples.
Hi Olst
I'm not sure what the above error is but I'm thinking that perhaps you could benefit from using the XSLTToJson package? You can get the package here: http://our.umbraco.org/projects/developer-tools/xsltojson
/Jan
is working on a reply...