Jquery Ajax Posting json to webservice

后端 未结 6 553
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 06:15

I am trying to post a JSON object to a asp.net webservice.

My json looks like this:

var markers = { \"markers\": [
  { \"position\": \"128.3657142857         


        
6条回答
  •  迷失自我
    2020-11-22 06:52

    Please follow this to by ajax call to webservice of java var param = { feildName: feildValue }; JSON.stringify({data : param})

    $.ajax({
                dataType    : 'json',
                type        : 'POST',
                contentType : 'application/json',
                url         : '<%=request.getContextPath()%>/rest/priceGroups',
                data        : JSON.stringify({data : param}),
                success     : function(res) {
                    if(res.success == true){
                        $('#alertMessage').html('Successfully price group created.').addClass('alert alert-success fade in');
                        $('#alertMessage').removeClass('alert-danger alert-info');
                        initPriceGroupsList();
                        priceGroupId = 0;
                        resetForm();                                                                    
                    }else{                          
                        $('#alertMessage').html(res.message).addClass('alert alert-danger fade in');
                    }
                    $('#alertMessage').alert();         
                    window.setTimeout(function() { 
                        $('#alertMessage').removeClass('in');
                        document.getElementById('message').style.display = 'none';
                    }, 5000);
                }
            });
    

提交回复
热议问题