CodeIgniter Forums

Full Version: Database LiveSearch
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4

El Forum

[eluser]sanir[/eluser]
ok, now check through search area.

El Forum

[eluser]boltsabre[/eluser]
Quote:Message: Undefined index: partialSearch
You're not getting your post array index "partialSearch"

Code:
function getSearchResults(value) {
   alert(value)
   $.post("getSearchResults.php",{partialSearch:value}, function(data){
    $("#search_results".html(data));
   });
and alert/check if value actually contains something. If it doesn't $_POST['partialSearch'] will be empty, thus false, thus undefined (I think).

El Forum

[eluser]joe.afusco[/eluser]
Alert is working fine.

El Forum

[eluser]boltsabre[/eluser]
Okay, so your alert is alerting your value, so we know that that is working
Code:
public function getSearchResults()
{
// $this->load->database();  
  $partialSearch = $_POST['partialSearch'];
  var_dump($partialSearch);
and comment out the rest of the code, what kind of variable is $partialSearch?

And are there any error in Firebug console?

El Forum

[eluser]joe.afusco[/eluser]
$partialSearch is a string. It will be used to reference phone numbers. since it is currently checking users email address', I keep searching for the first few characters of my email that is on the user table.

firebug console shows:

POST http://localhost/crm/index.php/search/getSearchResults 500 Internal Server Error

El Forum

[eluser]boltsabre[/eluser]
Are you sure CSRF is not set to true in your config file?

El Forum

[eluser]joe.afusco[/eluser]
Hmm. It was set to true. Sorry, when you asked if it was autoloaded earlier, I didn't set it to autoload. Didn't know it was in the config file. Sorry about that.

It is all working properly now. Thank you all for all the help.

El Forum

[eluser]boltsabre[/eluser]
lol... yeah, okay, just so you know what was happening:
CSRF was set to true (to prevent against cross site hacking). Because you were submitting $_POST values but without the CSRF code/hash it was failing and returning the internal 500 error - which is a good thing!

Basically you want to keep it enabled/set to true, so your work is not quiet over yet. Just do a google on "codeigniter submit form via ajax with CSRF enabled" to figure it out, there are a couple of options (I'm at work, cannot remember the syntax off the top of my head).

Glad we got there in the end!
Pages: 1 2 3 4