1

The below is my code java script which working in Firefox very well but not in chrome or other.

$.getJSON('http://localhost:8080/myapp/getUploadStatus.htm?jsoncallback=?', function(data) {alert(data)});

And in server side i'm returning proper JSON data with the json function name like.

jQuery15205480379721357835_1345286865781({"percentage":0,"cpercentage":0,"cfile":"23.gif","uploadFiles":"noData"})

This working fine in FF but not in any other, In chrome it's not hitting to my server also. Means the request is not going to server. Any help will be greatly appreciated.

4

2 回答 2

1

我总是将以下 jQuery 用于 JSON javascript

var thedata = "hey";    
$.ajax({
     type:'POST',
     dataType: 'json',
     url: 'your url',
     data: 'mydata='+thedata,
     cache: false,
     success: function(data) {
       alert(data.callback);
     }
    });

还有一个PHP示例:

if(isset($_POST['mydata'])) {
 $callback = "This is what I've got: ".$_POST['mydata'];
 echo json_encode(array('callback'=>$callback));
}

在这个简单的示例中,您将收到一个 JS 警报:这就是我所拥有的:嘿

于 2012-08-18T11:04:47.637 回答
0

尝试使用

event.preventDefault();
于 2012-08-18T11:01:29.723 回答