Reputation: 10012
I have the following function:
function LogEvent(ID,description) {
var userName = document.getElementById('ctl00_ContentPlaceHolder1_username').value;
var download_link = document.getElementById('ctl00_ContentPlaceHolder1_url_download').value;
$.ajax({
type: "GET",
url: "Logger.aspx",
data: { person: userName, item: ID, desc: description },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: {
$.fileDownload(download_link);
}
});
}
Now I get an error around the $.fileDownload(download_link);
line.
Uncaught SyntaxError: Unexpected token .
If I remove the entire success section it works fine, if I replace the $.file... with alert('hi'); I get a similar error.
Note, the filedownload function is the jquery.download plugin, but I know the issue is more general as noted when using alert - which also doesn't work.
I'm not sure where I am going wrong with this code?
Upvotes: 1
Views: 126
Reputation: 33163
You've forgotten the function()
part of the callback function, or you're mixing object and function notations.
success: function() {
$.fileDownload(download_link);
}
Upvotes: 3
Reputation: 11467
It should be
success: function() {
$.fileDownload(download_link);
}
As it is, the parser is probably assuming
{
$.fileDownload(download_link);
}
is an object, which doesn't make sense since objects should be key-value pairs.
Upvotes: 3