title: After Add the Record Alert Message is not displayed Servlet Ajax
body: <p>After Add the Record  Record is insert into the database successfully but Alert Message is not displayed using Servlet Ajax. i am tring this since yesterday i didn't solve the problem yet.  what i tried so far i attached below. i don't know what was the problem is.i need to display alert message after add the record thats what i need.</p>
  
  <p><strong>Form</strong></p>
  
  <pre><code>&lt;div class="col-sm-4"&gt;
  &lt;form class="card" id="frmProject"&gt; 
      &lt;div class="bg-2form-group" align="left"&gt;
          &lt;label class="form-label"&gt;First Name&lt;/label&gt;
          &lt;input type="text" class="form-control" placeholder="First Name" id="fname" name="fname" size="30px"  required&gt;
  
      &lt;/div&gt;
       &lt;div class="bg-2form-group" align="left"&gt;
          &lt;label class="form-label"&gt;Last Name&lt;/label&gt;
          &lt;input type="text" class="form-control" placeholder="Last Name" id="lname" name="lname" size="30px"  required&gt;
  
      &lt;/div&gt;
  
  
      &lt;div class="card" align="right"&gt;
  
          &lt;button type="button" id="save" class="btn btn-info" onclick="addProject()"&gt;Add
          &lt;/button&gt;
          &lt;button type="button" id="clear" class="btn btn-warning" onclick="reSet()"&gt;Reset&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Jquery</strong></p>
  
  <pre><code>var isNew = true;
              function addProject()
              {
                  if($("#frmProject").valid())
                  {     
                      var url="";
                      var data= "";
                      var method;
  
                      if(isNew==true)
                      {
                          url = 'add';
                          data = $("#frmProject").serialize();
                          method = 'POST'
                      }
                      else
                      {   
                          url = 'update';
                          data = $("#frmProject").serialize() + "&amp;catid=" + catid;
                          method = 'POST'
                          console.log(data);
                      }
                      $.ajax({
                          type: method,
                          url : url,
                          dataType: 'JSON',
                          data : data,
  
                          success:function(data)
                          {
                              if(isNew ==true)
                              {
                                  alert("Record Adddeddd");
                              }
                              else
                              {
                                   alert("Record Updatee");  
                              }        
                          }   
                      }); 
                  }
              }
  </code></pre>
  
  <p><strong>Servlet Page</strong></p>
  
  <pre><code>Connection con;
      PreparedStatement pst;
      response.setContentType("text/html;charset=UTF-8");
  
      PrintWriter out = response.getWriter();
      String fname = request.getParameter("fname");
      String lname = request.getParameter("lname");
  
  
           Class.forName("com.mysql.jdbc.Driver");
           con = DriverManager.getConnection("jdbc:mysql://localhost/details", "root", "");
           String query = "insert into record(firstname,lastname)values(?,?)";          
           pst = con.prepareStatement(query);        
           pst.setString(1, fname);
           pst.setString(2, lname);
           pst.executeUpdate();
  
           String greetings = "Record Addeddddd ";
           response.setContentType("text/plain");
           response.getWriter().write(greetings);
  </code></pre>