HI I am trying to save data using web services-jquery and json, from some example on the web I wrote a similar code but a String instead of int:
//-----------------------------------------
<div id="dialogL" title="Create a new Layer">
<p>Enter Name:</p>
<input id="txtValue1" type="text" size="40" />
<p>Enter Description:</p>
<textarea id="txtValue2" rows="4" cols="30"></textarea>
<br />
<input type="button" value="Create" onclick="Save()" />
//--------------------------------------------
<script type="text/javascript">
function Save() {
$.ajax({
type: "POST",
url: "testservice1.asmx/Save",
data: "{ 'value1': " + $("#txtValue1").val() + ", 'value2': " + $("#txtValue2").val() + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: Success,
error: Error
});
}
function Success(data, status) {
}
function Error(request, status, error) {
alert("Error: " + request.statusText);
}
</script>
//-------------------------------------
[WebMethod]
public bool Save(String value1, String value2)
{
DoSave();
return true;
}
But this didnt work , give me back an internal error message. What did I do wrong?