Welcome Guest, Not a member yet? Register   Sign In
Ajax and mysql
#8

[eluser]xwero[/eluser]
Ajax provides javascript with the opportunity to call other urls to manipulate or fetch data. It's like using an api.

So you can call any controller method want. You can create an ajax specific controller or you can add the ajax methods to the 'normal' controller. That is for you to decide.

A basic example. You have a controller and method user/update. With jQuery you do
Code:
$.ajax({
   type: "POST",
   url: "index.php/user/update",
   data: $("form").serialize(), // get all the form field values
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
});
msg is a string that is echoed by the method. you can send a plaintext string or a formatted string (json,xml). If you send success and error strings in plain text you can prefix them with error : and success : .

I suggest you read as much as you can about ajax and learn to use the methods of the library you are going to use.


Messages In This Thread
Ajax and mysql - by El Forum - 08-26-2008, 08:26 AM
Ajax and mysql - by El Forum - 08-26-2008, 08:44 AM
Ajax and mysql - by El Forum - 08-26-2008, 09:02 AM
Ajax and mysql - by El Forum - 08-26-2008, 09:11 AM
Ajax and mysql - by El Forum - 08-26-2008, 09:11 AM
Ajax and mysql - by El Forum - 08-26-2008, 02:58 PM
Ajax and mysql - by El Forum - 08-27-2008, 01:49 AM
Ajax and mysql - by El Forum - 08-27-2008, 02:12 AM
Ajax and mysql - by El Forum - 08-27-2008, 02:41 AM
Ajax and mysql - by El Forum - 08-27-2008, 02:46 PM
Ajax and mysql - by El Forum - 08-28-2008, 03:31 AM
Ajax and mysql - by El Forum - 08-28-2008, 03:37 AM
Ajax and mysql - by El Forum - 08-28-2008, 05:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB