The result that is currently returned is raw text, which means data[0] accesses the first element (i.e. character) of the string, which is {. Obviously, you want to turn the returned data into a JSON object. To do this, jQuery.ajax() has a nifty property called dataType, which determines the way jQuery interprets the data returned from the AJAX call. Possible values are 'xml', 'json', 'script', and 'html'. Simply set the dataType parameter to 'json' in your code and you’re set!
jQuery.ajax( {
type: 'POST',
url: '/wp-admin/admin-ajax.php',
data: StockSymbolUI,
dataType: 'json',
success: function( data ){
jQuery( '.stock-table-outer' ).show();
jQuery( '.stock-table-outer' ).html( data );
}
} );
Related Posts:
- JSON parsing error syntax error unexpected end of input
- Jquery Ajax Posting JSON to webservice
- TypeError: $.ajax(…) is not a function?
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- AJAX returns response 0
- How to Use JSON With AJAX?
- How to get those data using with ajax json?
- Intergrating agile carousel to wordpress: how to write the ajax_callback function
- 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()
- jQuery AJAX add json2 dependency?
- Pass request headers in a jQuery AJAX GET call
- data.map is not a function
- jQuery Ajax error handling, show custom exception messages
- How to send multiple data fields via Ajax?
- My javascript is returning this error: $.ajax is not a function
- jQuery AJAX cross domain
- Ajax TypeError: $.POST is not a function
- jquery loop on Json data using $.each
- XML Parsing Error: not well-formed in FireFox but good in Chrome
- Ajax Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
- How to fix the ‘Missing required request header. Must specify one of: origin,x-requested-with’ Ajax Error
- What’s the point of the X-Requested-With header?
- SON Post with Customized HTTPHeader Field
- jQuery posting JSON
- how to loop through JSON array in jQuery?
- How to get a cross-origin resource sharing (CORS) post request working
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- jQuery Form Validation before Ajax submit
- jQuery – Illegal invocation
- Javascript : array.length returns undefined
- $(document).ready(function() is not working
- jQuery ajax error function
- How to manage ajax calls and JSON in wordpress
- ajax stopped working when not logged in?
- Using jQuery to delete data stored in wp_options
- WordPress AJAX File Upload – FrontEnd
- How to add a ” waiting” icon for an ajax in WP frontend?
- What is the simplest ajax upload plugin or script to be used with wordpress?
- AJAX nonce with check_ajax_referer()
- Creating Ajax backend for Specialised Page Template? Should admin-ajax.php be used?
- How to get the path to current theme, but from a JS file?
- WordPress Ajax URL for function in functions.php
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- wp_mail script with jQuery post
- Ajax call does not activate callback function
- AJAX call returns 0
- AJAX function returning -1
- call shortcode in javascript
- WP set auth cookie using Ajax is not saved to browser
- jQuery and AJAX Not working with Select Form Element
- How to pass both action and formdata in wordpress ajax?
- jquery & ajax getting data to php in wordpress
- jQuery AJAX form validation
- Passing a varible from jQuery to PHP
- Proper way to load a single post via Ajax?
- Basic WordPress AJAX Call
- Trying to get single posts to load on the front page via ajax
- ajax call in wordpress front end
- AJAX post into pop-up div
- Bind to WPSetAsThumbnail
- Ajax not firing properly using Firefox, but works in Chrome
- jQuery Ajax() doesn’t work when the page is accessed as a WordPress template page
- Appending anchor tag to next post
- wp_localize_script, variable is not defined in jquery
- How to load whole WordPress pages dynamically with AJAX/jQuery like this following website?
- Using wp_ajax and wp_ajax_nopriv hooks
- WP REST return value to error function from Request
- Creating custom AJAX requests
- How to pass jQuery ajax URL value
- Registration e-mail check with AJAX
- Basic ajax call in WordPress
- Updating User Profile with AJAX not working
- how to get the comment ID in the front end when the REPLY button is clicked?
- Auto Load New Posts
- Admin wp_ajax hook returning 0
- wp_ajax() question.. not using wp_enqueue_script?
- wp_ajax unauthenticated and authenticated
- Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author
- WordPress ajax function parameter value not being passed
- WordPress Ajax not function as I expect… what’s wrong?
- Accept AJAX call with serialized form data
- wp_verify_nonce not working
- Tags in WordPress 3.2
- php ajax problem – weird 301 responses!
- WordPress customizer refresh screen after save
- Is there a restriction in WP on the use of jQuery load function?
- Loading posts via AJAX in a hidden div with updated URL?
- How to get a value from PHP in Jquery through Ajax
- Not sure why wp_ajax isn’t working?
- Load created php file data via ajax
- JSON output returns page source code [closed]
- Jquery not showing in homepage
- Ajax not posting form data to query in PHP function
- jQuery Ajax returning correct Response, but after redirect to 404 Error
- WordPress Ajax problem with undefined url
- Front-end Ajax File Upload
- Correct way to write jQuery functions in WordPress
- Display data on same page as form without refresh