Welcome Guest, Not a member yet? Register   Sign In
Handling errors differently when calling from Ajax
#4

[eluser]jonez[/eluser]
It's not quite ready for release (why I haven't posted it yet) but you can see example code in my Github repo: https://github.com/monsterlane/codeigniter3-app

Download that and follow the install notes to setup a new site. In the controllers/example folder you'll see some JS files. In script.js you'll see a call to this.getConduit( ).ajax. It's a wrapper that accepts an object (your $.post parameters) and calls $.ajax within that function. It wraps the callback you pass in in another function that does the decode etc.

https://github.com/monsterlane/codeignit.../assets/js
Check out the JS files and you'll see all the parts that make up that call.

app.js is a global object used to namespace everything.
app.module.js is the base client side module (example's script.js extends this)
app.conduit.js is the AJAX conduit system, modules create instances of conduits when called

You don't need all that if you just want to create your own wrapper. Once you see the flow feel free to copy/paste out whatever pieces you need. The documentation isn't the best yet, if you have questions let me know where and I'll add more comments.


Messages In This Thread
Handling errors differently when calling from Ajax - by El Forum - 12-27-2013, 01:21 PM
Handling errors differently when calling from Ajax - by El Forum - 12-27-2013, 02:05 PM
Handling errors differently when calling from Ajax - by El Forum - 12-27-2013, 02:41 PM
Handling errors differently when calling from Ajax - by El Forum - 12-27-2013, 03:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB