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 correctly add Javascript in functions.php
- How to loop through JSON data in wordpress WP REST API
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- WP API V2 returning Invalid User ID
- Removing jQuery migrate and working with dependencies
- Export all post from database to JSON only when the database gets updated
- How do I add a php statement to a jQuery string
- Looking for a better way to handle an ajax script that pulls in post data on click
- Looping through WP_Post Object
- Can’t use get_results() in ajax query
- Using a javascript file to access a get posts array
- Problem with WordPress Ajax form
- Generate an array of parent/child page IDs, based on parent page name
- How do I output a database option that is an array into a get_posts array?
- Access/update database with jQuery
- how to decode % in app [closed]
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- Passing jQuery value using Ajax to a page template
- ajax_object is not defined when ajax calls the function
- Why is this Ajax not working?
- Ajax return code 400
- Show post in slider
- woocommerce registration form with klaviyo(don’t work with current user)
- Using a variable in is_page(array())
- Remove duplicates – array_unique()
- Conditional Header in wordpress
- How to select the contents in the text view textrea in wp_editor?
- Proper syntax or method for keeping url in modified isotope / category links
- get_the_tags() not iterating through for/while loop, but will with foreach
- get a simple array of all of the term names that exist in all taxonomies
- How to use $query->set with post__in?
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Reprinting tags with all attributes
- Ajax date_query not working past the first iteration
- Limit Widgets to Sidebar ID’s
- database sent to a JSON file
- [jQuery]Adding shortcode
- Display parent and child taxonomies in separate drop down select fields
- Add / Update Custom Fields After Select Pictures in Media Window
- WordPress admin-ajax.php 400 bad request
- JSON REST API WordPress only showing first 10 categories
- How to keep track of when a vote is cast?
- How to say if meta_value is greater than 0 in an array?
- Only show first image in foreach loop
- How can I get all values from my array in a loop in php? [closed]
- Get all posts as an array ID => Name
- Output votes to div dynamically in wordpress
- Separate array output into a
- JS file is not loading when i put wp_head() and wp_footer
- Angular not defined [closed]
- add the value of a variable returned in a while loop [closed]
- limit number of post for achive page
- Set cookie for visitor
- Update value of a associative array with update_post_meta
- Adding wp_list_categories to a specific div that was appended using jQuery
- MySQL Query Returns Array () In Shortcode
- How to send a php var to jQuery Ajax call with two different file
- How do I call a value from the datase using ajax
- Create an array with all the links of the years’ archive (of a custom post type)
- Redux option doensn’t seem when include from functions.php
- Dropdown Category form. Only show Sub-Categories
- Where to add my PHP codes for AJAX Jquery to work?
- How to use wp_ajax_set_post_thumbnail?
- Display one random image from Media Library
- How to reload a php script, using AJAX and jQuery
- Using wp_editor() when not logged stopped working
- Move Jquery.js to Footer
- Need help to create WordPress page that decodes a text file and publishes it in JSON format
- get_category_parents to array
- number of posts with “Load More”
- How to call WordPress PHP file using external js file
- How can i iterate through this shortcode array?
- Ajax not updating to database
- jQuery doesn’t work in my php snippet
- Ajax Load more CPT via shortcode
- how to remove/exclude html coding from json file while export?
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- Non-array argument in array_merge()-function [closed]
- Combining fancybox with multiple thumbnail plugin
- Highlight posts currently being edited on multiple editor site?
- Showing all post from all post type in admin backstage
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- Add specific phrase after every product title including the discounted price? [closed]
- Adding Custom JQuery Menu Fresh Slide Out
- Load Meta box value into div AJAX [duplicate]
- Retrieve Array from within Array [closed]
- How to group by column a and sum column b and c in a php array
- PHP how to submit array elements to database