Reputation: 3999
It would be hugely appreciated if you could just run through this code and see if you spot an "unexpected identifier". Thanks so much guys.
javascript:(function () {
url = document.location.href;
if (url.match('youtube.com/watch?')) {
var s=document.createElement('script');
s.setAttribute('src','http://jquery.com/src/jquery-latest.js');
document.getElementsByTagName('body')[0].appendChild(s);
dataString = 'url=' url;
$.ajax({
type: 'POST',
url: '/create/',
data: dataString,
success: function(data){ console.log(data); }
});
}
else {
alert('This is not a youtube video.')
}
})();
Upvotes: 0
Views: 563
Reputation: 50205
Just to be more different...
dataString = 'url=' url;
should be:
var urleq = 'url=',
dataString = [urleq, eval(urleq.substr(0,urleq.length-1))].join('');
Upvotes: 0
Reputation: 93694
This:
dataString = 'url=' url;
Should be:
dataString = 'url=' + url;
Mind you, you can avoid awkward string concats by giving $.ajax
an object to work with - especially useful if the number of params increases:
$.ajax({
data: {url: url}
});
Upvotes: 7
Reputation: 64177
You assignment of dataString is not concatenating properly:
dataString = 'url=' url;
should be:
dataString = 'url=' + url;
Upvotes: 2