0

my web side html code like this

$.ajax({
type : "Get",
url : "http://localhost:9999",
data : {"servicename" :"test"},
timeout:100000,
beforeSend: function(xhr) { 
             },
success: function(rs) {
        alert("[success]"  + rs);
      },
complete:function(XMLHttpRequest,textStatus){
              if(XMLHttpRequest.readyState=="4"){
                  alert("response text= " + XMLHttpRequest.responseText);
              }
              },  
     error: function(XMLHttpRequest,textStatus,errorThrown){
              alert("error:"+textStatus);
          }       
});

I Use url querystring (http://localhost:9999?servicename="test") can receive data ,but i use jquery reveive nothing. jquery version is 1.4. Netty Server is run example HttpSnoopServer.java.

Chuck Norris
  • 15,207
  • 15
  • 92
  • 123
  • several thing that come to my mind: 1. Is localhost:9999 the exactly same server AND port your current page is running on? 2. Try not to mix upper and lower case ... it's get, or GET. 3. You are using XMLHttpRequest as a parameter which is also a property of the global window object. Try to omit beforeSend, complete and error for testing purposes. – devnull69 Feb 20 '12 at 08:07

1 Answers1

0

After running this locally my guess is the same as devnull69. You can not make an XMLHttpRequest to localhost from another domain.

Cross-site XMLHttpRequest

Try executing the same javascript in chrome's console or in firebug's console, it should spit out an error about domain access.

Community
  • 1
  • 1
roby
  • 3,103
  • 1
  • 16
  • 14