0

Below is my ajax call:-

$.ajax({
            url: '/bin/commersenext/assetUpload',
            type: 'POST',
            contentType:'application/json',
            data: JSON.stringify(ob),
            dataType: 'json',
          success:function(msg){
            alert("data"+msg);
              console.log(msg);
            }

        });

and when trying to read the data

String tabledata = request.getParameter("data");

getting null pointer exp.

But if i use below line of code m able to read the data.

BufferedReader br = new BufferedReader(new 
InputStreamReader(request.getInputStream())); 
Akki
  • 1
  • 3
  • The problem is in your datatype and data parameters, try removing the datatype attribute and see the result. – Fady Saad Jun 30 '17 at 05:58

1 Answers1

1

You can only get the POST data if it is encoded as key-value pairs of content type: "application/x-www-form-urlencoded"

otherwise use a BufferedReader see https://stackoverflow.com/a/3831791/2310289

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64