FAQ

[Catalyst] Ajax Problem.

Kieren Diment
Jan 5, 2011 at 12:04 pm

On 05/01/2011, at 10:51 PM, Mahmoud Mehyar wrote:

Well, I don't see why you put results in stash, can you send your controller
code snippet, it has to send a response but let's look at that first

I also recommend you to use a javascript framework maybe jQuery, like
catalyst, it will make your life easier
Unless you have a very well defined reason not to use a javascript framework (e.g. very exotic client side platform) there's no reason not to use your javascript framework of choice. If you have to roll your own ajax stuff then you ought to be being paid properly for doing so. Once you work out the basics of jquery (my recommendation, but there are similar alternatives), then all this stuff becomes trivial, as does the catalyst back end.
On Wed, Jan 5, 2011 at 2:07 PM, Rohan M wrote:

Dear All,

I want to use Ajax in my Catalyst application.

Thing's that I've done till now :

1) Created a Javascript function on an event (onblur event) in my view (tt
page).
2) Created xmlhttp object in that Javascript function.
3) Called the '/controller/action' path with parameters.
4) The Action subroutine searches database and puts results in the *stash*
*
*
*I could see, the things are working till the fourth step correctly.*

Now, how can I render the stash variables in the current tt page?

Or Will I need to parse the entire content?

Is there a better solution for this problem?

Any help or similar (simple) example will be appreciable.

CODE SNIPPET
======================================================================>>
function getDetails(id)
{
var param = "id="+id;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.open("GET","/indexer/getid/"+"?"+param,true);
// /controller/action url
xmlhttp.send();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status= 0)
{
document.getElementById("data").innerHTML=xmlhttp.responseText;
// the element to render output
}
}
show();

}

======================================================================>>

Thanks and regards,
Rohan


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
reply

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions