serkah2018-03-30 06:21:46
serkah, 2018-03-30 06:21:46

Ajax + Routing?

with an ajax request, I prescribe a route that refers to the controller, in which there is already a ready-made method, but there is no connection
already checked everything 15 times, everything seems to be correct
- the routes work here -

; Конфигурационный файл - карта УРЛ, именно здесь определяется как будут выглядеть урл на вашем сайте
; Секции - определения УРЛ, директивы - имена переменных и различные условия для них.
; Например чтобы УРЛ: http://www.example.com/news/2006/03/21
; запускал контроллер "news" с действием "list" и параметрами year, month и day (для $_GET).
; Напишите следующее правило
; [news/@year/@month/@day => news#list]
;	require_regex.year = /^\d{4}$/
;	require_regex.month = /^\d{1,2}$/
;	require_regex.day = /^\d{1,2}$/
; Для создания именованных мапов используется запись вида
; [products:products/list => products#list]
; [product:product/@id => products#view]
; Далее в коде программы можно будет использовать функции помощники вида products_url(), products_path() и product_url(1342), product_path(1342)

[regions/region_search => card#region_search] //мой роут где card-контрллер/region_search - метод

url ajax request is the following - regions/region_search
and the method in the card controller -
if (action() == 'region_search'){
        $referal  = $_POST['data'];

when requesting for regular pages, after clicking on the links, the routes work as they should, everything works fine.
does not want to catch dynamic requests

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Alexander, 2018-03-30

What do you mean by "no connection"? What response from the server comes with what headers and statuses?
Perhaps these links are for following them inside the browser, and not API methods?
API methods should generally return JSON objects and are not meant to be navigated from a browser

ThunderCat, 2018-03-30

- open the browser console, go to the network tab
- turn on XHR requests
- poke into your ajax and see what went, where it went and what was said from the server.
- After that, we think - whether we went there and whether we got it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question