javascript - Post or Get data not present from ajax request -



javascript - Post or Get data not present from ajax request -

i want validate value entered in text input field using ajax request server when seek access post or data, both empty arrays.

the html input:

<input type="text" name="club_key" id="club_key" class="form-control" onblur="verifykey(this);">

the javascript:

function verifykey(ev) { var url = '/index.php?/orders/key'; // url = encodeuricomponent(url); $.ajax({ cache: false, url: url, type: "post", data: ev.value }).done(function(response) { alert(response); });

the server side php:

public function check_key() { echo '<pre>'; echo "clubbbed death: "; // print_r($this->input->get_post()); print_r($_get); print_r($_post); echo '</pre>'; }

both empty arrays. there no post or info present. site codeigniter site, in routing have:

$route['orders/key'] = "orders/check_key";

i have tried:

$route['orders/key/(:any)'] = "orders/check_key/$1";

any ideas why there's no post data?

php expects form submissions (via , post) in key = value format. data: ev.value value: ev.value. since there's no key, php cannot set $_get or $_post, because array entries must have key.

try

data: {foo: ev.value}

and then

$_post['foo']

alternatively, try

$value = file_get_contents('php://input');

which read bare string straight input, it'll unprocessed php.

javascript php jquery ajax codeigniter

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -