Send decimal number as json parameter to web service
Hi, I have a json call that consumes a web service, it request several parameters, all of them string, but one of them is a decimal, something like this for example "2.21" as string, however, jQuery keeps crashing with error "500 undefined" if that parameter contains a dot, however if I change it to comma, it works, but the number is stored in the database as integer, with no coma, this my my code:
- function addReportLine()
- {
- var productVal = $("#productCode").val();
- var nameVal = $("#productName").val();
- var unitVal = $("#unitPrice").val();
- var qtyVal = $("#qty").val();
- var totalVal = $("#totalPrice").val();
- var whVal = "";
- var userVal = $("#username").val();
-
- $.ajax({
- type: "POST",
- contentType: "application/json",
- url: "http://IP/Service1.svc/testMethod",
- data: JSON.stringify({ productId: productVal, productName: nameVal, warehouse: whVal, unitPrice: unitVal, totalPrice: totalVal, qty: qtyVal, currentUser: userVal }),
- dataType: "json",
- success: function (data){
- populateReportGrid();
- },
- error: function(result){
- alert(result.status + ' ' + result.StatusText);
- }
- });
- }
It works great if the parameter "unitPriceVal" does not contain dots, but I need that so I can store the right number in the database, is there any way to send the value with the dot and save it in the server? Thanks a lot!