Answer the question
In order to leave comments, you need to log in
How to solve the problem with AJAX and PHP?
Hello.
I have a list of news in my project and on each such news there is a “Participate” button, when clicked, the following should happen - JS (AJAX) will process the click of this button and pass a certain value to a PHP script that will add a user ID to the database, which pressed this button.
In the process, I had a problem that if you call this file via AJAX, then it will no longer be possible to connect third-party files in the file, which is called via AJAX . That is, it is impossible to call a function from another file that is connected to what is called via AJAX.
Right now I have this code:
<script>
function AjaxFormRequest(id)
{
$.ajax({
type: "POST",
url: "system/user_request.php",
data: {id: id},
success: function(data){alert(data)}
});
}
</script>
<?php
require_once 'engine.php';
$site->userRequestInProject($_POST['id']);
?>
Answer the question
In order to leave comments, you need to log in
And the AJAX request is sent correctly, haven't you looked? Well, there is no chance 404 or 500? And does the send work at all?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question