Zhaocaipeng
Zhaocaipeng

Reputation: 1

cross-domain ajax request get 412

I have to do across-request from iPad to access tomcat webapp, sometimes this works, but if you send request repeat, the tomcat will return a 412 code. help!
The ios's codes is

$.ajax({
    type:"POST",
    url:[this is not a link]("http://192.168.1.222:8080/cmcp/doLogin"),
    timeout:600000,
    data: JSON.stringify({userName:"admin",password:"admin"}),
    dataType:"json",
    contentType: "application/json",
    success: function(nowData,textStatus,XMLHttpRequest )
    {

    },
    error :function(msg) {

    }
}); 

Upvotes: 0

Views: 173

Answers (1)

Subedi Kishor
Subedi Kishor

Reputation: 5996

Use dataType JSONP instead of JSON. JSONP is a viable solution for cross-domain Ajax

dataType: 'JSONP'

Please have a look at Exaples and Cross-domain Ajax -- brief introduction.

Upvotes: 2

Related Questions