EllisLab text mark
Advanced Search
     
ajax passing value in codeigniter
Posted: 11 October 2012 01:12 AM   [ Ignore ]
Avatar
Joined: 2012-10-10
38 posts

$.ajax({
  type: “POST”,
  async:false,
  url: “test/aj”,
  data: dataString,
  success: function(text)
  {
}
the echo item is not returning to function(text)

 
Posted: 11 October 2012 01:23 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3796 posts

use a full url, check in firebug/console to see that the ajax request is being sent to the correct url and also the post data.

 Signature 
 
Posted: 11 October 2012 01:41 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-10
38 posts

i am new in codeigniter ,test is class and aj is function ,so i just pass the value to that functon and does not return any thing

 
Posted: 11 October 2012 01:44 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3796 posts

Which means nothing to your ajax request, since it’s javascript and not CI.  Again, try using a FULL url (http://yoursite.com/test/aj) or whatever in the ajax request…

Use a javascript console in your browser to see the ajax request and check if it’s going to the right place.

 Signature 
 
Posted: 11 October 2012 02:15 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-10
38 posts

console reply is “NetworkError: 404 Not Found - http://localhost/CodeIgniter_2.1.2/test/aj”

 
Posted: 11 October 2012 03:14 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
102 posts
stv - 11 October 2012 02:15 AM

console reply is “NetworkError: 404 Not Found - http://localhost/CodeIgniter_2.1.2/test/aj”

Means your ajax request goes to the wrong address or your controller dont respond the way you like. Is the controller itself working proper?

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 11 October 2012 03:20 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-10
38 posts

controller is working properly but all paths is not working properly, any problem in routes,config

 
Posted: 11 October 2012 03:35 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
102 posts

If this is your path “http://localhost/CodeIgniter_2.1.2/test/aj” ...

- There could be a problem with special chars in url
- There could be a problem with your .htaccess
- There could be a problem with your routes.php

Just some ideas

 

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 11 October 2012 07:43 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-10
38 posts

Problem solved ,any how still have confusion about paths..thnx buddy

 
Posted: 11 October 2012 07:44 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
102 posts

http://ellislab.com/codeigniter/user-guide/general/routing.html

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/