3

I got error

No route found for "POST /module/getinfo/0/0/1454306400000/1455256800000"

The code on index.html.twig:

var desde_=1454306400000;
var hasta_=1455256800000;
var url = "{{ path('module_getinfo') }}"+desde_+"/"+hasta_

to get something like this:

url = /module/getinfo/1454306400000/1455256800000

the routing.yml is:

module_getinfo:
    pattern: /getinfo/{desde}/{hasta}/
    defaults: { _controller: AcmeDemoBundle:Module/Module:getInfo,desde:0,hasta:0}

I want to create a custom variable on javascript, what can I do ?

Thank you !

PD. Sorry for my english, I'm still learning jejeje

2 Answers 2

5

If you don't pass the values of the route placeholders to the path() function, it'll use the default values (both set to 0).

If you can't pass the values, because they are only available in JavaScript, consider using string replacing techniques:

var url = "{{ path('module_getinfo', { desde: '%desde%', hasta: '%hasta%' }) }}"
    .replace('%desde%', desde_)
    .replace('%hasta%', hasta_)
;
Sign up to request clarification or add additional context in comments.

Comments

0

A simple solution is to use what @wouter J said But a cleaner solution is to use something like fos js routing which allows you to generate the routes from java script

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.