1

I use NanoHTTPD as web server in my Android APP, I submit some date using the function SubmitCheckedItemsForm() in client.

In web server client, I can receive "POST" method information when I lanuch the code in both FireFox and Chrome, but I receive "GET" method information when I lanuch the code in IE 11.0? Why?

Server Code

@Override
public Response serve(IHTTPSession session) {
  String uri = session.getUri();
  Method method = session.getMethod();
  Utility.LogError("Method: "+method);
}

HTML

<form action="" method='post' enctype='multipart/form-data' id="FormForAction">
</form>

JS

function SubmitCheckedItemsForm(action) {

    var mytemp = GetArrayOfCheckedItems();
    var formID = "#FormForAction";

    $(formID).unbind("submit");

    alert(mytemp);

    $(formID).submit(function (eventObj) {

        $(formID).empty(); 

        $('<input />').attr('type', 'hidden')
           .attr('name', action)
           .attr('value', JSON.stringify(mytemp))
           .appendTo(formID);
    });

    $(".FilenameCheckboxForSelect").prop("checked", false);

    $(formID).submit();
}

Modified JS

function SubmitCheckedItemsForm(action) {

    var mytemp = GetArrayOfCheckedItems();
    var formID = "#FormForAction";

    $(formID).unbind("submit");

    alert(mytemp);

    $(formID).submit(function (eventObj) {

        $(formID).empty(); 

        $('<input />').attr('type', 'hidden')
           .attr('name', action)
           .attr('value', JSON.stringify(mytemp))
           .appendTo(formID);

        $('<div>Body</div>').appendTo(formID);
    });

    $(".FilenameCheckboxForSelect").prop("checked", false);

    $(formID).submit();
}
HelloCW
  • 843
  • 22
  • 125
  • 310

2 Answers2

1

Finally I found out this. That when you use the browser to send an HTTP POST request in Internet Explorer 11. When a HTTP POST request is sent without a message body, the GET method is used instead. This is a browser issue. You can check it on the Microsoft support page also. Here: issue with Form method attribute

AsthaUndefined
  • 1,111
  • 1
  • 11
  • 24
0

That is not your code problem but the browser's problem. If you want to try you can try this:

There is an option of Enabling/Disabling protected mode in IE and this option is enabled by default for “Internet” zone and “Local Intranet” zone(or any one of them). Disabling at these 2 places may solve the issue.

Tools -> Internet Options -> Security -> Internet/Local Intranet -> Uncheck on the "Enable protected mode" option. Just try this if it solves the problem.

Sample code:

<form action="your_action_page" method="post" enctype='multipart/form-data' id="FormForAction">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit"> 
</form> 
AsthaUndefined
  • 1,111
  • 1
  • 11
  • 24