Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery使用AJAX,不调用操作也不显示输出。但是,如果没有ajax,我们可以使用旧方法_Javascript_Jquery_Struts2 - Fatal编程技术网

Javascript Jquery使用AJAX,不调用操作也不显示输出。但是,如果没有ajax,我们可以使用旧方法

Javascript Jquery使用AJAX,不调用操作也不显示输出。但是,如果没有ajax,我们可以使用旧方法,javascript,jquery,struts2,Javascript,Jquery,Struts2,我正在使用Ajax async从数据库中提取一个报告。。当我使用此代码时,我能够做到这一点 function showCustomer(str) { alert("Report is loading..!Please wait"); var xmlhttp; if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest)

我正在使用Ajax async从数据库中提取一个报告。。当我使用此代码时,我能够做到这一点

function showCustomer(str)
{
    alert("Report is loading..!Please wait");

var xmlhttp;    
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","Pull.action?rel="+str,true);
xmlhttp.send();
} 
但是当我尝试使用jquery ajax时,我无法获得输出

$(document).ready(function() {
    $("#submit").click(function(event){
        $("#submit").hide();
        $('#txtHint').text("Loading..! Please Wait. !!");
        var name = $("#first").name();

        alert(name);

        $.ajax({
            type: "GET",
            url:"Pull.action?rel="+name,
             context: document.body,
            success: function(data){
                alert(name);
$('#txtHint').html(data);
                //$('#txtHint').load("Pull.action?rel="+name);
                $("#submit").show();
            }           
        });
    });
 });
我在这里是否犯了什么错误,它并不是说“拉动动作”也是一种动作

正在使用的JSP是

<form action=""> 
<table><tr><td>
<s:select id="first" label="Please select the Go Live Date : "  name="applicationPhases" value="%{applicationPhases}" headerValue="--Select--"
  list="{'--Select--','Q1','Q2','Q3','Q4','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'}" />
</td><td>
<s:submit id="submit" name="submit" value="Submit"  />  
</td></tr> </table>
</form>
<br /><br />
<br />
<div id="txtHint" />





请帮助我使用jquery发出ajax请求,从jsp调用一个动作类,并在同一个jsp中显示输出。。(输出将是display tag table,变量必须通过url传递到action类)

这个Jquery ajax帮助我达到了我的要求

$(document).ready(function() {
    $("#report").click(function(event){
        $("#report").hide();
        $('#txtHint').text("Loading..! Please Wait. !!");
        var name = $("#first").val();
        alert(name);
        $.ajax({
            type: "GET",
            url:"Pull.action",
            data:{"name":name},
            context: document.body,
            success: function(data){
                $('#txtHint').html(data);
                $("#report").show();
            }    
    error:function(){
                          $('#txtHint').html(data);
                          alert("Error in pulling details");
                            }
        });
    });
 });

如果遇到错误,请添加此方法并检查获取错误消息错误:function(){alert('error while response..);}@pappu_kutty我已尝试放置错误消息。但是,它没有显示任何东西。。即使如此,我也没有收到那个警报(“名称”)。。“Pull.action”类将提供列表,该列表稍后将使用display标记在jsp中显示。如果您没有收到警报,则可能存在语法问题。启动页面后,如果您使用chrome或firefox,请在chrome中按ctrl+shft+j(调试)并查看问题所在。您是否在控制台(浏览器控制台)中看到任何错误?出现语法错误。现在我可以从这个JSP调用其他操作。但是,无法在请求中传递参数。。请让我知道我在这里犯了什么错误。下面是ajax jquery调用