Parsing php string in jquery [closed]

Well it seems @JacobPeattie mentioned to use json, I just echoing that.

  1. First json encode the variable $array = json_encode($out);

  2. Then send this value echo '<div data-ad = '.$array.' class="ash_loadmore"><span>LOAD MORE</span></div>';

  3. 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 {}