Syntax problem or bug?

Asked

Viewed 73 times

1

I’m using onclick to run a Javascript when a button is clicked on the dropdown-menu.

The problem is in view:

screenshot indicando erro

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:

Unterminated string constant

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.

  • how is your js ?

  • Hi @Jcsaint, edited my post, there added code Js.

  • You tried to put ; in the end ? onclick="suaFuncao();"

  • Hi @Jcsaint, yes I tried putting a semicolon (;) and it’s still the same

  • Have you tried removing parentheses ?

  • Yes, still the same problem

  • Sometimes the problem disappears

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.