Monday, 26 August 2013

Calling controller function from within view/javascript

Calling controller function from within view/javascript

In the past I have successfully executed my ASP.NET MVC controller
functions within my view in javascript using ajax, but for some reason in
this case it isn't working...
My code is set up as follows:
var Fingerprint =
{
//...
scanimage: function(templateType, imageType, numAcquisitions, num)
{
//...
return 'YES';
},
//...
DidRecieveImage: function(ImageData, imageType, rowCount, columnCount)
{
// ...
// I would like to call my controller function here
return 'YES';
},
Before I used ajax in the way of:
var url = '@Url.Action("ControllerAction","Controllername")';
$.ajax({
url: url,
data: { 'String': String },
success: function (response) { window.location.href = response.Url; },
type: 'POST',
dataType: 'json'
});
where the url pointed to the controller action, but for some reason when I
use this method here it won't call the function.
Any ideas why this is happening?
Thanks

No comments:

Post a Comment