Welcome Guest, Not a member yet? Register   Sign In
CI and Ajax or JQuery
#1

[eluser]Unknown[/eluser]
Hi, I'm having a little trouble about implementing ajax. I'm really new on this, but as much as I review the code I don't found were's the problem.
Here's the fact:

I have a simple controller that calls a view. This view shows some information. Well, I really got angry when I tried to use a simple button showing an alert. The alert down't show. However, other alerts seems to work. I can not see what am I doing wrong. Here's the code:

[removed][removed]
[removed]
$(document).ready(function() { //this alert worksa fine

alert ('Hello World');

});

$('#message').click(function () { // this alert doesn't appear!
alert ('Hi!');
});
[removed]

....


<input type="button" value="Hi" id="message">

If somebody can help me.... I'll be greatfull

TNX
Sorry about my english
#2

[eluser]psychoder[/eluser]
put your .click() function inside document.ready

Code:
$(document).ready(function() { //this alert worksa fine

  alert (‘Hello World’);

  $(’#message’).click(function () { // this alert doesn’t appear!
    alert (‘Hi!’);
  });

});
#3

[eluser]Unknown[/eluser]
[quote author="psychoder" date="1329185669"]put your .click() function inside document.ready

Code:
$(document).ready(function() { //this alert worksa fine

  alert (‘Hello World’);

  $(’#message’).click(function () { // this alert doesn’t appear!
    alert (‘Hi!’);
  });

});
[/quote]

All Right, that worked, but if I remove the part of $(document).ready.... it don't work. That my problem. I mean, when I remove it an only let

$(’#message’).click(function () { // this alert doesn’t appear!
alert (‘Hi!’);
});

and click on the button, the alert doesn't show!
#4

[eluser]InsiteFX[/eluser]
Next time please post in the correct forum topic! This forum is for user contributed libray code etc.




Theme © iAndrew 2016 - Forum software by © MyBB