Question

[Solved] jQuery not working: Processing instruction not closed

The JSP code is:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
 <%@ include file="headpl.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <script>
                $(document).ready(function(){

                    $('#editform').hide();

                    $("#clickedit").click(function(){
                        $("#editform").toggle(500);
                    });

                });
        </script>
    </head>
    <body>
        <hr width="1" size="600" style="position:absolute; left:450px; top:250px;" />
        <div id=edit  style="position:absolute; left:100px; top:600px;">
                <p><a id="clickedit" href="">Edit personal details </a></p>
        </div>

        <div id=editform style="position:absolute; left:100px; top:650px;">
            <form>
            <p>First name: <input type="text" name="fname" value="<%=request.getAttribute("fname")%>" required/>
            </p>
                    <p>Last name: <input type="text" name="lname" value="<%=request.getAttribute("lname")%>"/>
                    </p>
                    <p>E-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="email" name="email" value="<%=request.getAttribute("email")%>"/>
                    </p>
                    <p>State:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                        <input type="text" name="state" value="<%=request.getAttribute("email")%>"/>
                    </p>
                    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="submit" value="Save changes"/>
                    </p>
            </form>
        </div>
    </body>
</html>

The jQuery code isn’t working. The eclipse was earlier showing an error:

Processing instruction not closed.

But I did Ctrl+A -> Backspace -> ctrl+Z

and the error was removed I don’t know how, but the error vanished.

But still the jQuery code isn’t working. I don’t see any error, but some of you would?
I know the ques is way to low but I was trying for a long time, looked other similar questions as well but nothing is working.

Enquirer: Nivedita

||

Solution #1:

You need to disable the default action of following the link, which is reloading the page.

$(document).ready(function () {

    $('#editform').toggle();

    $("#clickedit").click(function (e) {
        e.preventDefault();
        $("#editform").show();
    });

});

DEMO

Respondent: Nivedita

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy