1
I’m using onclick
to run a Javascript when a button is clicked on the dropdown-menu.
The problem is in view:
Full code of the above image:
/*Linha 1*/ <div id="context-menu4">
/*Linha 2*/ <ul class="dropdown-menu" role="menu">
/*Linha 3*/ <li style="cursor:pointer" onclick="ApagarImagem4()"><a tabindex="-1">Apagar</a></li>
/*Linha 4*/ <li style="cursor:pointer" onclick="location.href='@Url.Action("DownloadImagem", "Account", new {imagem = "Image4" })'"><a tabindex="-1">Baixar imagem</a></li>
/*Linha 5*/ <li><a tabindex="-1">Something else here</a></li>
/*Linha 6*/ <li class="divider"></li>
/*Linha 7*/ <li><a tabindex="-1">Separated link</a></li>
/*Linha 8*/ </ul>
/*Linha 9*/ </div>
Javascript code:
function ApagarImagem4(){
$.ajax({
url: '/Account/Apagar_Imagem4',
type: 'POST',
data: { imagem :"Imagem4" },
success: function (response) {
if (response.Success)
{ alert("Sucesso")}
}
});
}
It seems that you did not like parenthesis "Erasing 4()". The problem was on line 3.
In the error list, shows a yellow warning:
Then, when you restart Visual Studio, the warning disappears. Sometimes when I have it executed, it shows this warning.
Some solution ?
A tip: avoid using images.
– Jéf Bueno
how is your js ?
– JcSaint
Hi @Jcsaint, edited my post, there added code Js.
– Matheus Miranda
You tried to put
;
in the end ?onclick="suaFuncao();"
– JcSaint
Hi @Jcsaint, yes I tried putting a semicolon (;) and it’s still the same
– Matheus Miranda
Have you tried removing parentheses ?
– Guilherme Branco Stracini
Yes, still the same problem
– Matheus Miranda
Sometimes the problem disappears
– Matheus Miranda