0
I have never made a Jquery script that queries with PHP via POST.
What I’ve managed to do is this:
$('a.js-cd-panel-trigger').click(function(e) {
e.preventDefault();
var valor = $(this).attr('id');
$.ajax({
type: "POST",
url: "php/fetch.php",
data: {
key: valor
},
dataType: "json",
cache: false,
success: function(result) {}
})
});
I gave an Alert in 'id' (variable 'value') and is bringing the id that I will query in PHP. If I give a inspect element in Chrome and it’s in "Network", the functions I’ve already customized in other projects, I can see the return here.
But in this case, there is no return, it seems that is not communicating with the other side (PHP).
If it works, I will assign the values in some tags.
Hello, can you tell us if in your Browser console you have an error ? such as: $ is not defined. If so. You can add a reference from the Jquery library to access AJAX functionality, you can download or just include the CDN link in your HTML where the form is. Link to download library: https://jquery.com/download/ Link to Ajax documentation: http://api.jquery.com/jquery.ajax/ It’s easier if you send us what’s going on on your console. so we can help with more assertiveness.
– user63886
The return is stored in
result
, inside the callbacksuccess
. You can use it from within this function, which is called when the request is successfully completed.– bfavaretto
Got it. But it would have some way to display the result in the browser itself?
– Rogério Pancini