Welcome Guest, Not a member yet? Register   Sign In
problam with AJAX and YATS
#1

[eluser]A.M.F[/eluser]
hi all,

i am trying to learn ajax, and i have my simple ajax code:
Code:
function load_list(listURL) {
    defaultList = listURL;
    
    display('ajax_wait', 'block'); display('list_rants', 'none');
    
    new Ajax.Updater('list_rants', listURL, {
        onComplete:function(request) {
            display('ajax_wait', 'none'); display('list_rants', 'block');
        }
    });

}

function display(element, style) {
    eval("document.getElementById('" + element + "').style.display = style;");    
}

(it's from the ranting site that someone posted here once)

and this is some of the php:
in the view:
Code:
<?=anchor('#', 'ניסיון', array('id'=>'cat_0', 'onclick'=>"load_list('".site_url_rel('show/test')."'); return false" ))?>
    <div id="list_rants"></div>

in the controller:

Code:
function test()
{
    header('Content-type: text/html; charset=utf-8');
    $this->layout->buildPage('test');
}

i should get the content that inside the test.php file right? but no, i get nothing.

thanks for ur time
#2

[eluser]A.M.F[/eluser]
someone plz?
#3

[eluser]Nick Husher[/eluser]
I'm going to guess and say that your problem is with this:
Code:
array('onclick'=>"load_list('".site_url_rel('show/test')."')
In an anchor function this should parse to:
Code:
&lt;a href="..." onclick="load_list("show/test")" &gt;...</a>

The inner doublequotes on your load_list function are breaking the document flow. The onclick won't be parsed properly and you'll get some sort of error.




Theme © iAndrew 2016 - Forum software by © MyBB