R
R
Ruslan Dzh2019-02-25 13:55:19
Joomla
Ruslan Dzh, 2019-02-25 13:55:19

How to accept result of php script in ajax request?

I can't figure out how to get the result of a php script in an ajax request. The situation is this:
1. There is a php request that clings to the mysql database (the database is not jooml), pulls out the necessary information and returns it via echo as an array (of type String, because I used json_encode()).
2. There is a joomla in which a plugin is installed only for working with html, js (php does not understand requests, you cannot install other plugins, in view of certain features.)
3. I would like to implement an ajax request (and finally understand how it works) which would it execute a php request when updating the page, get its result and place it in a variable accordingly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Pitalenko, 2019-02-25
@rdzh

$(document).ready(function(){
$.post('php.php' /*путь к php файлу*/, {a:fnumb, b:snumb} /*переменные может быть пустыми*/, function(data /*вот переменная которую возвращает php*/){

    });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question