I'm the author of the original post you linked to.
A few things to try out:
- Add a breakpoint to the JavaScript function: if it doesn't hit, something's wrong with your JavaScript.
- Check your browser's network activity: In
Chrome
, underDeveloper Tools
, go to theNetwork
tab and attempt the upload. See if it is hitting the right URL. - Make sure you're using
'@Url.Action...'
inside a Razor view. It won't work in external JavaScript files.
If you need @Url.Action
, you can probably use it in your Razor view, assign it to a temporary global variable and use it in your external JavaScript file.
In your View, add the following before the reference to your external JS:
<script type="text/javascript">
var audioAction = '@Url.Action("Upload", "Audio")';
</script>
In your JavaScript file, change '@Url.Action("Upload", "Audio")'
to audioAction
, as in:
function AudioUpload(title, description) {
Recorder.upload({
method: "POST",
url: audioAction,
audioParam: "Recording",
params: {
"Title": title,
"Description": description
},
success: function (responseText) {
alert(responseText.Success);
},
error: function () {
alert("error");
},
progress: NULL
});
}