I am trying to echo data from php to jquery and the problem is that somehow jquery is not passing the data to php. The var_dump of the variable $url echo's string'' or NULL.
Expected output is to echo what the user had typed on the input field on screen where the id="domain-hits" is.
HTML
<div id="domain-hits"></div>
<input onblur="checkPR()" type="text" class="input_text_metas_submit" name="url" value="http://" id="urlpr" />
Jquery / AJAX
$(function () {
jq2('#urlpr').on('blur', function (e) {
$.ajax({
type: 'post',
url: 'onlydomain.php',
data: $('#urlpr').serialize(),
success: function (data) {
$("#domain-hits").html(data);
}
});
e.preventDefault();
});
});
PHP - onlydomain.php
<?php
$url = isset($_GET['url']) ? $_GET['url'] : '';
var_dump($url); // it echo's string ''.
?>
I am a noob in ajax please help me on this, it's much appreciated. Thanks.