I am sure i am doing something bad here, but i cannot figure out what.
<script type="text/javascript">
$(function () {
$("li").bind("click", function () {
var sel = $(this).attr('id').toString();
$.ajax({
type: "POST",
contentType: "application/json",
data: sel,
url: "Default.aspx/SaveValue",
dataType: "text",
success: function (data) {
alert(data.d);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
}
});
});
});
</script>
Any advises please?
And here is the debug info gathered
UPDATE: By changing to data: "{var1:'test'}", and dataType: "json", everything works as expected
By changing to
data: "{var1:'test'}",anddataType: "json",everything worked as expected.Special thanks to Sparky and to all commenters of course