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.
I'm always using the following jQuery for JSON javascript :
var thedata = "hey";
$.ajax({
type:'POST',
dataType: 'json',
url: 'your url',
data: 'mydata='+thedata,
cache: false,
success: function(data) {
alert(data.callback);
}
});
And an PHP example:
if(isset($_POST['mydata'])) {
$callback = "This is what I've got: ".$_POST['mydata'];
echo json_encode(array('callback'=>$callback));
}
In this simple example you'll get an JS alert: This is what I've got: hey
尝试使用
event.preventDefault();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.