jQuery ajax adds query string that Code Igniter fails on
I'm making an ajax request using jQuery that looks like this:
$(function ()
{
$.ajax({
// In my actual code the following is an absolute URL
url: "messages/1/new",
cache: false
});
});
(messages
is the action, 1
and 开发者_JAVA百科new
are arguments)
Using FireBug, I found the problem that the actual URL being sent is like messages/1/new?_=1293985116579
, but CodeIgniter creates a 404 error on this.
So, I would like to either (A) stop jQuery from appending the query string, or (B) set CodeIgniter to accept or ignore the query string.
Just so this question has an answer... codeigniter really prefers POST data. Make sure you send parameters using POST not GET when using Ajax and it will make things much easier!
You can also add the question mark in your Codeigniter config file as an allowed character so the get requests don't throw an error. You should still use POST data if possible though!
精彩评论