Welcome Guest, Not a member yet? Register   Sign In
Undefined Variable when calling method with AJAX
#5

[eluser]Dyllon[/eluser]
You're returning a view (HTML) in your set_background method and trying to alert a php variable in your jquery, that's not going to work.

Your method is returning HTML which you'll see if you alert the html

Code:
$("a.background_btn").click(function(ev){
    ev.preventDefault();
    alert("Hello");
    var url = $(this).attr("href");
    //alert(url);
    $.ajax ({
        url : url,
        type: "POST",
        success : function (html) {
         alert(html)
        }
    })
});

But that's a really frustrating and inefficient way to debug JS, if you don't already have it get firefox and install the firebug add-on it will make your life alot easier.


Messages In This Thread
Undefined Variable when calling method with AJAX - by El Forum - 01-11-2010, 06:21 AM
Undefined Variable when calling method with AJAX - by El Forum - 01-11-2010, 06:42 AM
Undefined Variable when calling method with AJAX - by El Forum - 01-11-2010, 06:52 AM
Undefined Variable when calling method with AJAX - by El Forum - 01-11-2010, 06:55 AM
Undefined Variable when calling method with AJAX - by El Forum - 01-11-2010, 11:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB