Welcome Guest, Not a member yet? Register   Sign In
Codeigniter + Jquery AJAX
#1

[eluser]obay[/eluser]
Hi all,

Forgive my noob-ness, but I cannot, for the life of me, understand why this piece of code doesn't work...

In my view:
Code:
function get_conflict() {
        alert('hi');
        $.post("/plan/test/", { username: 'test' }, function (data) {
            alert('yo');
        });
        alert('hello');
    }

In my 'Plan' controller:

Code:
function test() {
        return json_encode(array(5));
    }

The "hi" and "hello" gets executed, but the "yo" doesn't. Can somebody point me to the right direction?

Thanks very much for your time.
#2

[eluser]cahva[/eluser]
Use Firebug to see whats the response. It will execute the alert('yo') only if the post was successfull.
#3

[eluser]obay[/eluser]
I managed to solve this by using

Code:
<?= site_url('plan/test') ?>

rather than just

Code:
/plan/test
#4

[eluser]cahva[/eluser]
Yep.. And Firebug(or any other similar devtool on other browsers) would have showed you that Wink




Theme © iAndrew 2016 - Forum software by © MyBB