I have probably found the problem (after our little discussion).
For me it looks like the $postcode
isn’t send. Check the “Headers” tab from you screenshot – there would be info about the POST variables that were or weren’t sent. If the $postcode
isn’t send, you get from the query probably the codes that are empty:
SELECT count(*) FROM wp_cdata WHERE code="";
but that isn’t certain because code
is a MySQL reserved word which should be escaped by backticks, so you could try to change this but I think it won’t help.
The main problem I think is the jQuery.post format which I believe should be like (notice the curly braces containing the arguments):
jQuery.post(
yes.ajaxurl,
{action: 'searchdata', postcode: $("#postcode").val()},
function(response) {
jQuery("#searchresult").html(response);
$('span.loading').remove();
return false;
}
);
You can check the possible post call formats.