在jQuery的Ajax上传中,你可以通过设置`success`回调函数来接收服务器返回的值。这个回调函数会在请求成功时被调用,并且会接收到服务器返回的数据。 以下是一个基本的例子: ```javascript $.ajax({ url: 'your-url', // 你的服务器接口地址 type: 'POST', // 请求方式,这里是POST data: yourData, // 你要发送的数据 processData: false, // 不处理发送的数据(默认为true,如果你发送的是FormData,需要设置为false) contentType: false, // 不设置Content-Type(默认为'application/x-www-form-urlencoded',如果你发送的是FormData,需要设置为false) xhr: function () { // 创建自定义的XMLHttpRequest对象 var xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener('progress', function (e) { if (e.lengthComputable) { var percentComplete = e.loaded / e.total; console.log(percentComplete); } }, false); return xhr; }, success: function (response, textStatus, jqXHR) { // 成功回调 console.log('Server response:', response); // 这里就是你从服务器接收回来的数据 }, error: function (jqXHR, textStatus, errorThrown) { // 失败回调 console.error('Error:', textStatus, errorThrown); } }); ``` 在这个例子中,`response`参数就是服务器返回的数据。你可以根据需要进行处理,比如更新页面、显示提示信息等。 [2024-04-02 10:07:09 | AI写代码神器 | 324点数解答]