pass json parameter as variable to .load()

OnbuttonClick trying to Load Page via .load() POST method. Generated URL parameters and printed as JSON formatted in button attribute btn-url.

Issue: Parameter is not passed to .load() since i’m use javascript variable page

Code:

$(document).ready(function(){       
                $("#open-content").load($php_self,loadfunctions);
                $("#open-content").on( "click", ".tools a", function (e){
                    e.preventDefault();
                    $("#open-loading-div").show();
                    var page = $(this).attr("btn-url");
                    $("#open-content").load($php_self,page, function(){
                        $("#open-loading-div").hide();
                        loadfunctions();
                    });             
                });         
        });

Working Code:

$(document).ready(function(){       
                $("#open-content").load($php_self,loadfunctions);
                $("#open-content").on( "click", ".tools a", function (e){
                    e.preventDefault();
                    $("#open-loading-div").show();
                    /*var page = $(this).attr("btn-url");*/
                    $("#open-content").load($php_self,{"pndg":"nta%3d","nm":"umfuiefuzhk%3d","dpt":"sfi%3d}, function(){
                        $("#open-loading-div").hide();
                        loadfunctions();
                    });             
                });         
        });

I want the JSON stored in page variable to be passed as parameter to .load().

How to pass URL parameters from page Variable to .load() function?

Note: $php_self and page will access PHP file via POST method


Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.