The reason why it's falling back to a 404 page is because the $Action//$ID/$OtherID
only matches the add/5/6
, so the 7
still needs to be matched.
As for why your url_handler
isn't being matched, that comes down to what the shift point does. I'm going to use your code to try to explain it for you. Basically, the left of the shift point gets consumed by the match and the right is available for the next controller to try using.
The URL myajax/add/5/6/7
first gets sent to the Director
. Here it matches the myajax//$action/$a/$b/$c
, with $action = "add"
, $a = "5"
, $b = "6"
and $c = "7"
, with nothing left to be matched.
As the shift point is directly after myajax
, when passing control off to the AjaxPage_Controller
, only parts to the right of myajax
are sent along for further matching. So AjaxPage_Controller
gets given add/5/6/7
to match.
This doesn't match myajax/add/$a/$b/$c
as it doesn't start with a literal myajax
string, so the $Action//$ID/$OtherID
handler on the RequestHandler
class is tried. This matches and sets $Action = "add"
, $ID = "5"
and $OtherID = "6"
, with the 7 left over.
The add
action is then run (you can see {"result":18}
in your debug output) and returns nothing. Since it returns nothing, there's nothing to try matching the 7
against, so a 404 is generated as the URL hasn't been entirely processed by the last controller.
As to how to fix your code, I would change the myajax/add/$a/$b/$c
url handler to add//$a/$b/$c
, as the myajax
has already been consumed and it allows for $a
, $b
and $c
to all be optional.