jquery - 400 bad request while calling web service -


i'm getting bad request server while calling web service using jquery ajax post. code looks :-

$("#dailyentryupdate").click(function(){     event.preventdefault();     var values = $("#dailyentryform").serialize();     var id = billingobject[localstorage.index].billingid;      var parameters = values+"&id=" + encodeuricomponent(id);       console.log("  values "+ parameters);     $.ajax({           url: "http://localhost:8080/tims/rest/updateentry/update",           type: "post",           data: parameters,           success: function(){               alert("record updated successfully");           },           error:function(){               alert("failure");           }            }); }); 

and server side looks this

    @xmlrootelement @path("/updateentry") public class updateentryservice{      @post     @path("/update")     @consumes("application/x-www-form-urlencoded")     public void updatebillinglist(             @formparam("truckno") string truckno,             @formparam("source") string source,             @formparam("destination") string destination,             @formparam("bookingdate") string bookingdate,             @formparam("unloadingdate") string unloadingdate,             @formparam("weight") int weight,             @formparam("freight") float freight,             @formparam("advance") float advance,             @formparam("balance") float balance,             @formparam("commision") float commision,             @formparam("hamali") float hamali,             @formparam("delieverycharge") float delieverycharge,             @formparam("remarks") string remarks,             @formparam("detention") float detention,             @formparam("id") string id) {                entitymanager em = daohelper.getinstance().getentitymanager();               try{                 em.gettransaction().begin();                 billing bill = em.find(billing.class, id);                 bill.setadvance(advance);                 bill.setbalance(balance);                 bill.setcommision(commision);                 bill.setdelieverycharge(delieverycharge);                 bill.setdetention(detention);                 bill.setfreight(freight);                 bill.sethamali(hamali);                  dailyentry entry = bill.getentry();                 entry.setbookingdate(bookingdate);                 entry.setdestination(destination);                 entry.setremarks(remarks);                 entry.setsource(source);                 entry.settruckid(truckno);                 entry.setunloadingdate(unloadingdate);                 entry.setweight(weight);                  em.gettransaction().commit();               } {                 em.close();               }     } } 

you sending parameters in ajax post method.

you must send parameters as:

data: { key: value} 

format.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -