Send decimal number as json parameter to web service

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:

  1. function addReportLine()
  2. {
  3. var productVal = $("#productCode").val();
  4. var nameVal = $("#productName").val();
  5. var unitVal = $("#unitPrice").val();
  6. var qtyVal = $("#qty").val();
  7. var totalVal = $("#totalPrice").val();
  8. var whVal = "";
  9. var userVal     = $("#username").val();

  10. $.ajax({
  11. type: "POST",
  12. contentType: "application/json",
  13. url: "http://IP/Service1.svc/testMethod",
  14. data: JSON.stringify({ productId: productVal, productName: nameVal, warehouse: whVal, unitPrice: unitVal, totalPrice: totalVal, qty: qtyVal, currentUser: userVal }),
  15. dataType: "json",
  16. success: function (data){
  17. populateReportGrid();
  18. },
  19. error: function(result){
  20. alert(result.status + ' ' + result.StatusText);
  21. }
  22. });
  23. }
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!