• Resolved felipexx85

    (@felipexx85)


    PLEASE HOW TO

    $.ajax({ url: ‘formulario.php’,
    data: {action: ‘test’},
    type: ‘post’,
    success: function(result){
    $(“#box_button”).html(result);
    }

    });

    import my form from public html, how do i find diretory?

    ive create a js file that requisite this form.php on public, or other folder…
    how do i execute ?

Viewing 1 replies (of 1 total)
  • Plugin Author SilkyPress

    (@diana_burduja)

    There are a lot of things confused here.

    For the beginning, as recommended in the editor’s comment on the “Add JS Code” page, you’ll need to wrap your JS code in

    jQuery(document).ready(function($) {
      \\ your code
    });

    because of the jQuery noconflict mode used by default in WordPress (see this article).

    Then, the “url” cannot simply be a PHP file in your public_html folder, but it has to be WordPress built in AJAX url: /wp-admin/admin-ajax.php (see this article).

    Afterwards you can write a function hooked in the “wp_ajax_test” and “wp_ajax_nopriv_test” WP actions where you can process the $_POST variable sent by your AJAX code. The WP actions are called “wp_ajax_test” and “wp_ajax_nopriv_test” because you’ve set your “action” variable to “test”. They might also be called “wp_ajax_my_ajax_action” and “wp_ajax_nopriv_my_ajax_action” if you set your “action” variable to “my_ajax_action”.

    If you have more questions, please consider asking them on stackoverflow. Your issue is not related to this plugin directly, but generally to your understanding of the WordPress AJAX principles.

Viewing 1 replies (of 1 total)
  • The topic ‘PHP AJAX REQ’ is closed to new replies.