Saturday, June 25, 2022
HomeWordPress Developmentphp - Ajax name not working in wordpress by means of a...

php – Ajax name not working in wordpress by means of a plugin


I’ve 2 Ajax name the primary is working however when it ship the information to different the file send_data.php and when I attempt to run any wordpress operate which is add_post_meta it would not work!

This’s the primary ajax name okay now the information despatched to send_data.php file when I attempt to run any wordpress operate like this add_post_meta(2, 'dropbox', 'Senddataphp', false); it prints this error what I wish to do is fairly easy simply get the information from ajax insert into wp database however I’ve no thought everytime I work with js with php issues like this occurs. WHen I embrace require_once(ABSPATH . 'wp-config.php'); require_once(ABSPATH . 'wp-load.php'); the ajax name would not work as effectively

caught Error: Name to undefined operate add_post_meta() in C:xampphtdocswordpresswp-contentpluginsDropboxapiincludessend_data.php:17
        Stack hint:

First Ajax code

$.ajax({
        
                kind: "POST",
                url: 'wp-content/plugins/Dropboxapi/contains/send_data.php',
                knowledge: {
                    req: JSON.stringify(dropbox_links)
                },
        
                cache: false,
                success: operate(responseData) {
                    // think about using console.log for these form of issues.
                    console.log("Knowledge recived: " + responseData);
                    console.log("First Ajax" + dropbox_links);
        
        
        
                }
            });

Second Ajax code right here I attempted to execute a operate that take the despatched knowledge and insert into database however it would not work, dropbox.php file is the principle file of the plugin

$.ajax({
            kind: "POST",
            url: 'wp-content/plugins/Dropboxapi/dropbox.php',

            knowledge: {
                functionname: 'printdata2'
            },

            success: operate(obj, textstatus) {
                if (!('error' in obj)) {
                    var yourVariable = obj.outcome;
                    console.log("SEc Ajax" + dropbox_links + yourVariable);

                } else {
                    console.log(obj.error);
                    console.log("SEc1 errr Ajax" + dropbox_links +
                        yourVariable);
                }
            },
            error: operate(msg) {
                console.log(
                    " errrnot positive what to ask for right here to examine subject" +
                    msg);
            }
        });

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments