This should work like a champion, build an object as shown below, and stringify it as JSON.stringify(newObject) , then there will be no errors
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script> var newObject= new Object(); newObject.key= '123'; newObject.action='getorders' $.ajax({ url:"request.php", type:"POST", data:JSON.stringify(newObject), contentType:"multipart/form-data", complete:alert("complete"), success:function(data) { alert(data); }, error:function(){ alert("error"); }); </script>
source share