How to Transmit JSON Directly via $.ajax Rather Than a Query String
When working with jQuery's $.ajax method, you may encounter an issue where it automatically converts JSON data into a query string. To prevent this conversion and transmit actual JSON, follow these simple steps:
Here's an updated code snippet that implements both steps:
<code class="javascript">$.ajax({ url: url, type: "POST", data: JSON.stringify(data), contentType: "application/json", complete: callback });</code>
Additional Notes:
The above is the detailed content of How to Send JSON Data Directly with jQuery\'s $.ajax?. For more information, please follow other related articles on the PHP Chinese website!