Welcome Guest, Not a member yet? Register   Sign In
loading controller via jquery

uh.... was typing a very long comment and accidentally hit something on keyboard.... making everything disappear...

k, in short... you can pull the URL directly from the trigger elements...

<a href="&lt;?=site_url('controller/delete/'.$id);?&gt;" class="delete">Delete</a>

// JS
    var url=$(this).attr('href'); // jQuery way
    var url=ev.target.href; // Native javascript, faster

You could also define the base_url in javascript, but it's not 100% bullet proof with out some manual editting.
var base_url=wind0w.l0cation.hostname; // change 0 to o
That will give you only the hostname, so If your code is running in some folder, or with index.php, you'll have to add them manually.

Then about the action part, non AJAX wise, you may return TRUE/FALSE for Yes/No accordingly to continue the click event or stop it.

and about the $.post which you said not working... maybe it was about the URL which is not a good one, but with the above method, you'll always get a good one....

I suggest you to check what are the URL called in the Firebug/Chrome console, to see If it's a good URL or with some errors, either in PHP or JS.

grr... getting headache by typing the same stuff 2 times .-.

Messages In This Thread
loading controller via jquery - by El Forum - 02-23-2012, 04:39 AM
loading controller via jquery - by El Forum - 02-23-2012, 06:13 AM
loading controller via jquery - by El Forum - 02-23-2012, 09:16 AM

Theme © iAndrew 2016 - Forum software by © MyBB