How to use 'ajax content type json' in JavaScript

Every line of 'ajax content type json' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
39getContentType() {
40 return 'json';
41}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

19async function sendJson(url, data, type) {
20 return await $.ajax({
21 url,
22 type,
23 data: JSON.stringify(data),
24 contentType: 'application/json',
25 dataType: 'json'
26 });
27}

Related snippets