java - Calling servlet to load the data using jquery ajax? -


i new jquery. have servlet fetch data database , result kept request , same result retrieved in jsp file. have call servlet using ajax jquery load data. doing below. not loading. please me.

$('#myform #revert').click(function() {          $.ajax({             type: "get",             url: "./mycontroller",             success: function(msg) {                 <span style="color:green;font-weight:bold">successful</span>');             },             error: function(ob,errstr) {                 //todo              }         });          }); 

servlet code:

//service call gets data , result kept in request scope below request.setattribute("myresult", result); request.getrequestdispatcher("/web-inf/myscreen.jsp").forward(request, response); 

thanks!

ajax not normal httprequest,you canot forward or sendredirect ajax request

since asynchronous,you need write response ajax request

printwriter out = resp.getwriter(); out.println(resultstring); return; 

please read @balusc great answer :how use servlets , ajax?


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -