Well it seems @JacobPeattie mentioned to use json, I just echoing that.
-
First json encode the variable
$array = json_encode($out);
-
Then send this value
echo '<div data-ad = '.$array.' class="ash_loadmore"><span>LOAD MORE</span></div>';
-
To get that
echo json_encode($_POST['ad'])
I think that’s it.BTW you don’t have now that string problem as the output will be like this {"footer-insta":2,"sidebar-1":3}
you see it is wrapped by {}
Related Posts:
- Sending simple variable on single page to WP JSON
- Show the subcategory name based on current product
- How can i send id of the currently posted form data through json response in custom wordpress plugin?
- Remove item from post_meta array via AJAX
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- AJAX Filter WHILE Loop not working WordPress
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- JSON Object Value Show Undefine
- Force array to be a string [closed]
- get_body_params() is always empty in POST request
- How to pass php array to external js file in WordPress
- Ajax date_query not working past the first iteration
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- AJAX pagination, update current page
- Limit Widgets to Sidebar ID’s
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- Save Search System
- adjust section according to country?
- foreach loop still echoes array
- populate form fields in a loop with ajax
- dynamic dependent select dropdown
- Change “add to cart” button color based on Woocommerce product category [closed]
- How can I get the values of my WordPress $wpdb query in Jquery?
- Ajax request returns ‘Array’. How to output the actual results?
- Ajax load more button for comments wordpress
- Slick + PHP + ACF + JQuery slide reveal not working
- How to add a do_action on refreshing of WP customizer?
- Exclude posts based on meta value
- wp_enqueue_script seperately for each shortcode
- database sent to a JSON file
- Input data from email form not going to JSON file
- Gravity form built in Captcha
- Menu jumping when calling it via PHP
- Setting value of session with Ajax not working
- Click a radio button must set textfield value
- WordPress Multiple Navigation bars
- Checking array against author id in loop
- [jQuery]Adding shortcode
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- multiple taxonomy select display only one in front end
- Display parent and child taxonomies in separate drop down select fields
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Add / Update Custom Fields After Select Pictures in Media Window
- Post repeating with infinite scroll
- Plugins not working on AJAX requests
- Fetching instagram api not working on wordpress
- Fancybox type popup window that’s not an iframe
- How to disable controls in theme customizer?
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- JQuery calling a Custom PHP function (Works in Dev but not in WordPress)
- Jquery function working in Dev Console but not otherwise [duplicate]
- Form Security: nonce vs. jQuery
- How do I Import / Upload Files with jQuery AJAX?
- WordPress admin-ajax.php 400 bad request
- Alter required message using comment form api
- Why does wp_head hook my functions to the beginning of my source code?
- WordPress Ajax Call inserting data but success response false
- Automatically set all tags to have a height of 0 if there is no content inside the tag [closed]
- Advanced Custom Fields – display label and value only if value entered
- meaning of (array)function()
- Ajax contact form return 0
- Grouping posts by a custom meta value
- How can i display a jquery slide on front page
- AJAX – Returning Two JSON Objects with One PHP Function
- Pull GetOption() variable into jQuery dynamically created html
- Royalty-Free Sliders used in theme development
- JSON REST API WordPress only showing first 10 categories
- wp_force_remove_style’ not found
- Error – ‘create_function is deprecated’ [closed]
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- Unset session variable on page reload / setup but exclude AJAX
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How can I access string value in an array?
- Add Ajax Hooks and Call from Custom Template PHP
- How to use if statement in an array? [closed]
- How to array only one key from another array
- WordPress Ajax Always returning 0
- Filtering a function’ output for a new continued function
- Is it save to use eval for a jQuery callback method coming from the database?
- Jquery window.send_to_editor function
- Double jQuery loaded
- Trying to prepend a Hashtag symbol to the_tags links [closed]
- Get html data with javascript to php array and store to wordpress database
- Flexslider won’t work on WordPress
- Function won’t run onclick using Ajax
- How do I create a numbered list with PHP? [closed]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Javascript not loading on certain page
- Theme not calling Jquery properly
- How to keep track of when a vote is cast?
- How to use array in function to get only value I want
- Error while setting role
- Get categories names as an array to use it in theme settings
- WordPress plugin admin page – using WordPress function in linked php file
- How to add drag and drop functionalities to a div inside option panel
- How to get the last category name of a child category?
- How to say if meta_value is greater than 0 in an array?
- How to use two meta_compare in an array?