嗨,我有以下代码:
page1.jsp 点击按钮时调用的ajax函数
function ajaxFunction()
{
var xmlHttp;
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
alert("Data loaded");
}
}
xmlHttp.open("GET","page2.jsp",true);
xmlHttp.send(null);
}
page2.jsp
<%@ page import="javax.jms.*" %>
<%!
private QPublisher qPublisher = null;
public class QPublisher {
private TopicPublisher publisher = null;
private TopicSession session = null;
public void configPublisher(){
TopicConnectionFactory factory = null;
TopicConnection connection = null;
try {
factory = new com.tibco.tibjms.TibjmsTopicConnectionFactory("tcp");
connection = factory.createTopicConnection("user","pwd");
session = connection.createTopicSession(false,javax.jms.Session.AUTO_ACKNOWLEDGE);
javax.jms.Topic topic = session.createTopic("topic1");
publisher = session.createPublisher(topic);
}
}
public void publish(String msg)
{
javax.jms.TextMessage message = session.createTextMessage();
message.setText(msg);
publisher.publish(message);
}
}
public void jspInit(){
qPublisher = new QPublisher();
qPublisher.configPublisher();
}
%>
<%
qPublisher.publish("This is a test for TT");
%>
如果我在不使用 ajax 的情况下调用 page2.jsp,即从 page1.jsp 使用
<form action="page2.jsp">
消息由订阅者选择并显示。
但不是通过制作ajax ..
我对ajax有基本的了解,所以请指导我缺少什么?