Pergunta

I want to pass a certain url with anchor to cakephp as parameter. my ajax is as follows:

var next_url = 'www.domain.com/search#!query=blah%20secondBlah&times=5';
$.ajax({
    url : '/users/login/?next='+next_url,
    success: function(res) {
        // do something
    }
});     

In my controller, I run

debug($this->request->query['next']);

and it gets me only www.domain.com/search without the anchor part.

What to do?

CakePHP 2.3

Foi útil?

Solução

I would send next_url in the data option of $.ajax so it is properly URL encoded. Try this:

$.ajax({
    url : '/users/login/',
    data: {next: next_url},
    success: function(res) {
        // do something
    }
});  
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top