php call through ajax

Home Forums Quform WordPress php call through ajax

This topic is: not resolved
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #31923
    oivanr
    Participant

    Hi,
    I had been created a test form to make a ajax/php call. What I am doing is click an element call “consultar” and when it happen make an php call through ajax. This is the code that I had included in Custom JavaScript area.

    jQuery(function consultar($) {
    $(‘#consultar’).click(function () {
    jQuery.ajax({
    type: “post”,
    url: ajax_var.url,
    data: “action=” + ajax_var.action + “&nonce=” + ajax_var.nonce,
    success: function(result){
    $(‘#phpResult).html(result);
    });
    });
    });
    });

    I have two problems:
    The first is that quforms does not recognize the jquery.ajax function.
    The second is that I have to tell ajax to localize the script but what I can see is that if I use wp_enqueue_script I will get a conflict.
    Can you help me, please.

    #31924
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #31929
    oivanr
    Participant

    Thanks a lot for your quick response . I had try with your code, the issue is that when a call the “ajax_var.action” is due to I included that statement inside the plugin in the enqueue scripts action. I think is better to do this

    jQuery.ajax({
    type: ‘post’,
    url: the url of the plugin,
    data: ‘action= the name of the php hook or action’,
    success: function(result){
    $(‘#phpResult’).html(result);
    }
    Like you can see I delete de nonce because if I don’t use the enqueue action, I am not able to create a nonce inside the js code.

    I feel glad with your comments about this.
    Thanks again for your support.

    #31943
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #31953
    oivanr
    Participant

    Hi,
    Thanks to your help i had I had done the call. Now I want to send a message if a field required is empty but through js. How I can send a message like the message quform type? or better, how I can access this message.
    Thanks again,

    #31954
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy