‘data’ should be a stringified JavaScript object:
data: JSON.stringify({ "userName": userName, "password" : password })
To send your formData
, pass it to stringify
:
data: JSON.stringify(formData)
Some servers also require the application/json
content type:
contentType: 'application/json'
There’s also a more detailed answer to a similar question here: Jquery Ajax Posting json to webservice
Related Posts:
- SON Post with Customized HTTPHeader Field
- JSON parsing error syntax error unexpected end of input
- data.map is not a function
- Jquery Ajax Posting JSON to webservice
- TypeError: $.ajax(…) is not a function?
- jquery loop on Json data using $.each
- how to loop through JSON array in jQuery?
- jQuery – Illegal invocation
- Javascript : array.length returns undefined
- $(document).ready(function() is not working
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- How to get the path to current theme, but from a JS file?
- AJAX returns response 0
- How to Use JSON With AJAX?
- Cannot access elements of json object
- JSON output returns page source code [closed]
- How to get those data using with ajax json?
- Intergrating agile carousel to wordpress: how to write the ajax_callback function
- I want to import my Json file into a custom made display-modal. How do i link my Json file?
- Using WP_Query to grab custom meta values, foreach to json object
- How to retrieve WP_Object that is inside an array of another array
- Can’t add classes using jQuery from a JSON string with get_body_class()
- Parse wordpress blog data using json api and ajax
- Loop through WordPress API response errors
- How to send json data to jquery
- how to remove/exclude html coding from json file while export?
- Uncaught TypeError: Cannot read property ‘ajax’ of undefined
- jQuery AJAX add json2 dependency?
- getJSON on WordPress Page
- How to set time delay in javascript
- Disable button in jQuery
- Submit a form using jQuery
- Adding placeholder attribute using Jquery
- wait() or sleep() function in jquery?
- Force a default browser on my android phone using a simple html shortcut page
- Ajax Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
- $ versus jQuery
- Enable & Disable a Div and its elements in Javascript
- Which selector do I need to select an option by its text?
- Run ScrollTop with offset of element by ID
- Form Submit jQuery does not work
- jQuery multiple events to trigger the same function
- Using jquery to get all checked checkboxes with a certain class name
- How do I remove a box-shadow effect from an element when another element is hovered?
- jQuery delay not working
- How to get POSTed JSON in Flask?
- Validate form before submit jquery
- How to save the state of a drag and drop jQuery UI Sortables front end layout editor?
- How do I use WP’s jQuery
- Deregister WordPress jquery on specific page
- Fire jQuery function when post edit screen loads
- Add X meta box inputs based on form at top of meta box, how to do it right?
- Stylizing external SVG files with jQuery and CSS
- WordPress REST endpoint not able to reach with jQuery
- Execution of JavaScript on save post
- How do I pass WordPress’s get_bloginfo(‘siteurl’) to Jquery?
- Googles jQuery: Are There Avantages to Using It?
- Create URL with parameter for JQuery toggle status
- Stop theme’s jQuery function from running
- Making the wordpress login form a jQuery dropdown
- Not sure why wp_ajax isn’t working?
- WordPress Ajax problem with undefined url
- Use Media Uploader on Multiple Images on same page
- Move jQuery to the bottom of the page whilst keeping the WordPress jQuery
- How can I fire a jQuery event once getBlocks() actually returns the post’s blocks instead of null?
- WordPress + BlockUI or a splash page [closed]
- Add/remove action on jQuery toggle
- jShowOff not showing numeric links, shows ‘undefined’ instead
- Firebug says jQuery is loaded but $() and jQuery() are not defined
- Why is my WordPress loading old version of JQuery?
- delete post meta by AJAX
- url – ajax loaded but no JS
- merge wp rest api query to get posts per category does not work
- Why should I deregister jquery?
- jQuery does not work on WordPress editor
- how to json_encode(); the Loop content so that the encoded array is [“0”:content, “1”:content]
- Loading jquery locally
- How to call custom jQuery plugins into the customizer controls
- Change zurb foundation top bar style on.scroll in wordpress theme using jquery and css
- click event to unhide something after ajax not firing
- WP_ENQUEUE not working with Foundation 5
- Save jQuery UI Sortable on WordPress
- Why does WordPress load jQuery in my header instead of footer?
- Problem adding MP3 attachments to a jPlayer playlist
- wp_enqueue_script jquery and jquery ui not working
- Axis guidelines over an image
- jquery Autocomplete
- Homepage loads many unnecessary jquery-ui files
- Adding scripts before plugins scripts
- Refresh widget admin page resetting jQuery hidden class
- Autocomplete for titles via ajax – rework of past post away from like_escape()
- Bootstrap with Flexslider jQuery Issue
- Sorting UL Listing Within the TinyMCE Visual Editor in WordPress
- My .js file is getting a 404
- Contact Form 7 submission does not complete [closed]
- how to display post in jquery slider and carousel
- Carousel Hover Image
- What is calling jquery?
- Accessing Advanced Custom Fields with Repeater using jQuery instead of PHP
- Enqueued jQuery not working