无法在firefox中的ajax中获得成功的价值

时间:2017-02-06 13:51:45

标签: jquery ajax servlets callback jquery-callback

我没有在FIREFOX中获得Ajax成功的价值,它在IE和Chrome中运行良好。 Servlet代码:

BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
    response.setContentType("application/json;charset=UTF-8");String json = "";
    if(br!=null)
    {
        json=br.readLine();
    }
    System.out.println("JSON"+json);
    try {
        JSONObject jObj = new JSONObject(json.toString());
        Iterator iterKey = jObj.keys(); 

    // create the iterator for the json object.
    while(iterKey.hasNext()) {
        String jsonKey = (String)iterKey.next(); //retrieve every key ex: name, age
        String jsonValue = jObj.getString(jsonKey); //use key to retrieve value from 

        //This is a json object and will display the key value pair.

        System.out.println(jsonKey  + " --> " + jsonValue  );
        myData.add(jsonValue);
    }
    } catch (JSONException e) {
          e.printStackTrace();
        }

out.print("Hi");

JSP代码如下,它在IE和谷歌Chrome浏览器中运行良好。我还将updatef Firefox更新到最新版本。

function formSubmit(){
                var article = new Object();
                article.releasename=$('#dropDownRelease').val();
                article.morname=$('#dropDownMor').val();
                article.pathname=$('#dropDownPath').val();
                article.buildname=$('#dropDownBuild').val();
                article.filename=$('#filePath').val();
                $.ajax({
                url: 'UploadReportServlet',
                type: 'POST',
                dataType: 'text',
                data:JSON.stringify(article),
                contentType: 'application/json',
                mimeType: 'application/json',
                success: function (data) {
                     alert(data);
               },
               error:function(data,status,er) {
                   alert("error: "+data+" status: "+status+" er:"+er);
                  }
            });
        };

0 个答案:

没有答案