jQuery ajax call throws an HTTP 302

I’d say, just skip that:

 cookie: encodeURIComponent(document.cookie)

There’s no need to post any cookies on XHR – the browser handles that.

Well, how about something like that instead (untested):

data:{'term':encodeURIComponent($.term)}

Most easy is to use FireBug, open Net panel and inspect both HTTP headers.