I created a simple test for a function to grab the video id from a youtube url and echo it out. It works fine as is but when I introduce jQuery code in the mix I receive this error NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument. The error is commenting the jquery.js file on line 7071. I have no idea what to do or what is exactly causing this. The code is below.
First File
<script src="http://code.jquery.com/jquery-latest.js"></script>
<input type="text" id="url" />
<input type="button" id="press" value="click" />
<div id="return"></div>
<script type="text/javascript" >
$('#press').click(function () {
$('#url').val();
$.post('ajax_youtube.php', {url:url}, function(data) {
$('#return').html(data);
});
});
</script>
Here is the ajax_youtube.php file
<?php
function get_youtube_url($text) {
$text = preg_replace('~https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be/| youtube\.com\S*[^\w
\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w]*(?:[\'"][^<>]*>| </a>))[?=&+%\w-]*~ix',
'$1', $text);
echo $text;
}
$url = $_POST['url'];
get_youtube_url($url);
?>
$('#url').val();should bevar url = $('#url').val();