php - AJAX and $_POST field is not passed -
hello can guys give quick tip on i'm doing wrong here.
i want pass $_post['url'] php file via ajax.
ajax:
<script> $('#checkurl').click(function() { $('#loader').css("display","block"); $('#form').submit(function (e) { e.preventdefault(); $.ajax({ url: 'example.php', data: {url:'<?php echo $_post['url']; ?>'}, type: 'post', success: function(data) { $('#loader').css("display","none"); $('#reponse').replacewith(data); } }); }); }); </script>
form
<form id="form" method="post"> <input type="search" size="35" id="url" name="url" placeholder="www.myblogurl.com" class="btn btn-mod btn-gray btn-medium btn-round" /> <span class="hidden-xs"> </span> <input type="submit" value="submit" id="checkurl" class="btn btn-mod btn-medium btn-round mb-xs-10"> </form>
i know i'm calling php file, can var_dump random text it. var_dump($_post); empty.
array(1) { ["url"]=> string(0) "" }
try this
data: {url:$('#url').val()},
rather echoing php variable can url using jquery.
Comments
Post a Comment