I’m engaged on an arbor.js graph. What I would like is to ship member id question it from php return member tree son to once more to jquery script. then print the tree.
right here is HTML kind
<kind motion="" technique="post" id="blm_get_tree_view_meta_ajax_form" >
<?php echo $dropdown_html; ?>
<enter sort="hidden" title="action" worth="blm_member_tree_response">
<enter sort="hidden" title="blm_mem_tree_meta_nonce" worth="<?php echo $blm_add_meta_nonce ?>" />
<enter id="<?php echo $this->plugin_name; ?>-treeview_mem_id" sort="hidden" title="<?php echo "blm"; ?>[memid]" worth="">
<p class="submit"><enter sort="button" title="get_tree" id="get_tree" class="button button-primary" worth="GET TREE"></p>
</kind>
And that is the jquery script
<script>
jQuery( doc ).prepared( perform( $ ) {
"use strict";
$('#get_tree').on('click on',perform(){
var user_id = $('#binary-level-marketting-treeview_mem_id').val();
//console.log(user_id);
$.ajax({
sort:'POST',
url: params.ajaxurl,
knowledge:{motion:'blm_member_tree_response', user_id:user_id},
success:perform(knowledge){
if(knowledge.standing == 'okay') {
console.log(knowledge.nodes);
(perform ($) {
var Renderer = perform (canvas) {
var canvas = $(canvas).get(0);
var ctx = canvas.getContext("2d");
var particleSystem;
var that = {
// arbor.js rendering goes right here.
//....
//...
}
// and renderer
$(doc).prepared(perform () {
var knowledge = {
nodes: knowledge.nodes,
edges: knowledge.edges
}
var sys = arbor.ParticleSystem(700, 700, 0.5);
sys.parameters({ gravity:true});
sys.renderer = Renderer("#viewport");
sys.graft(knowledge);
});
});
})(this.jQuery);
php response perform as
public perform getTreeGraphView() {
if (isset($_POST['blm_mem_tree_meta_nonce']) && wp_verify_nonce($_POST['blm_mem_tree_meta_nonce'], 'blm_get_tree_view_meta_form_nonce'))
{
if(!empty($_POST['user_id'])){
$knowledge = array();
$mtree = new MemberTree();
$mtree->getMemberTree($_POST['user_id']);
$nodes_ = $mtree->getNode();
$edges_ = $mtree->getEdge();
$parent_ = $mtree->getParent();
$knowledge['nodes'] = $nodes_;
$knowledge['edges'] = $edges_;
echo $knowledge;
die( '0' );
}
wp_die();
} else {
wp_die(__('Invalid nonce specified', $this->plugin_name) , __('Error', $this->plugin_name) , array(
'response' => 403,
'back_link' => 'admin.php?web page=' . $this->plugin_name.'-product',
));
}
}
ajax motion
$this->loader->add_action( 'admin_ajax_blm_member_tree_response', $plugin_admin, 'getTreeGraphView');
enqueue scripting and localization did as it’s.
The method is 99% success however admin-aax.php returns 400 standing code. with following response
and likewise 0 append to output. I pit wpdie() at finish of the perform
I cant clear up the problem anymore. any skilled right here?