[3.7] AJAX History.pushState

Hi guys,

Im building a one page web application using ajaxify,
Everything is going great, but every time when javascript calls this function: History.pushState(null,‘en/welcome’,‘en/welcome’);
it tries to execute the handler and method: ‘en/welcome’

Can any one tell me how to avoid this?

Thanks in advance

Felipe Serrano

You do realise that it is the order you are passing the arguments?

Yuor code should be

History.pushState(null,title,url);

Thanks but that still does not do the trick, it calls a handler and and action, if I block this line: History.pushState(null,null,url);
it render finde the contentm, but the url it will be always welcome.

Thanks

Yes, my guess is that when you do it this way. You are not using an API URL to do your work, what that means is that when you call the url you are maybe getting the rest of the layout loaded as well.

The only way you can be sure, is to ALWAYS look into fireDebug or Chrome tools and look at what the URL looks like for the Ajax call, but more importantly, look at what is being returned.

That would be your first step in any situation with Ajax, this then can tell you what you are doing wrong.

In this case, you would need to use maybe an API module, or setup a set of handlers that will be only for Ajax and not call the layout for this so it returns just the data.

I’ll do my best Andrew… thanks :wink:

No problem, just remember that ColdBox returns layouts and views as default to any handler, unless told otherwise. This will help when it comes to ajax calls and you can’t go wrong.