Home › Forums › Quform WordPress › php call through ajax
- This topic has 5 replies, 2 voices, and was last updated 4 years, 2 months ago by Ally.
- AuthorPosts
- September 11, 2020 at 7:44 am #31923oivanrParticipant
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.September 11, 2020 at 10:19 am #31924AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
September 12, 2020 at 5:44 am #31929oivanrParticipantThanks 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.September 14, 2020 at 10:41 am #31943AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
September 17, 2020 at 1:23 am #31953oivanrParticipantHi,
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,September 17, 2020 at 9:31 am #31954AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.