I am doing a cross-site ajax to java data transaction(Not sure if I named that correctly, so please forgive me about that). Part of code in Java file:

BufferedReader input =
            new BufferedReader(new InputStreamReader(connectionsocket.
            getInputStream()));
DataOutputStream output =
            new DataOutputStream(connectionsocket.getOutputStream());
...
output.writeChars("some random text");
output.close();

Also I have index.php file with some jQuery:

$(document).ready(function() 
    {
        $("#send_data").click(function(){
            $.ajax({
                type: 'get',
                dataType: 'xml',
                url: 'http://localhost:1024/'+$("#command").val(),
                success: function(data) {console.log(data);},
            error: function() { console.log("Error"); }
        })
    });
});

The command is sent correctly and received in Java side correctly. Then the request from java to ajax is 200 OK too. The output is also working. (For example if I remove output.close(), I do see in the firebug, that it is waiting for the output to be closed.)

The only problem is, no matter what I do I get no response text. It's always an empty string :(

P.S. I made a mistake while writing here (because it was that I was trying everything I could think of), it has to be

dataType: 'text',

, but still, that doesnt solve the problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.