Call C# Function On Code Behind From Ajax Function
I've been trying to get to a code behind function to get two variables encrypted to return as querystrings. But I've been unsuccessfull. First time trying Ajax. So, in code behind
Solution 1:
You had an error in your javascript. resp.d instead of resp.data:
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me?fields=name,email', function (response) {
console.log('Successful login for: ' + response.name);
Ajax(response.email, response.name)
});
}
function Ajax(expressao1, expressao2) {
var requestObject = { str : expressao1, str2 : expressao2 }
$.ajax({
url: 'login.aspx/EncritaDados',
method: 'post',
contentType:'application/json',
data: JSON.stringify(requestObject),
dataType:'json',
success: function (resp) {
var strings = resp.data.split(";");
window.location.href = 'login.aspx?email=' + strings[0] + '&nome=' + strings[1];
},
error: function () { }
})
}
Post a Comment for "Call C# Function On Code Behind From Ajax Function"