Welcome Guest, Not a member yet? Register   Sign In
Jquery ajax and CI not working
#9

[eluser]cideveloper[/eluser]
So this is what I have and it works fine. Please show us your view "home" which is where you probably have your js loaded from and the item with id send. I have a feeling your external js file is not loading

Controller
Code:
<?php

class main extends Controller {

    function __construct()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->load->view('home');
    }

    function doajax()
    {    
        echo "asd";
    }
}
Javascript
Code:
$(function(){

$('#send').click(function() {

$.ajax({
    type: "POST",
    url: "/main/doajax",
    success: function(data){
        alert(data);
    }
    });

});    

});
View
Code:
<html>
<head>
<title>Welcome to CodeIgniter</title>
<p><br /><a href="#" id="send">send</a></p>
[<]script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"[>][<]/script[>]
[<]script type="text/javascript" src="assets/js/main.js"[>][<]/script[>]
&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
Jquery ajax and CI not working - by El Forum - 11-25-2010, 10:15 AM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 12:20 PM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 02:25 PM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 02:55 PM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 05:35 PM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 05:47 PM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 07:32 PM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 07:35 PM
Jquery ajax and CI not working - by El Forum - 11-25-2010, 07:43 PM
Jquery ajax and CI not working - by El Forum - 11-26-2010, 12:59 AM
Jquery ajax and CI not working - by El Forum - 11-26-2010, 11:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB