请我使用fineUploader页面, 第一页工作正常,但第二页不是:调试浏览器控制台的响应是:
0
[Fine Uploader 5.11.8]尝试解析xhr响应时出错 text(Unexpected token< in JSON in position 0)
对于第一点:(请求没有到达端点,因为我在端点页面中创建了一个测试人员,如果有任何脚本访问它的话)
所以第一页中的请求正常工作,并且在端点属性中具有相同路径的相同请求不在第二页
中工作我读了很多同样错误的文章,但所有这些文章都没有找到正确的终点路径,我在第一页中做了正确的测试。
var uploader = new qq.FineUploader({
debug: true,
element: document.getElementById('my-uploader'),
request: {
endpoint: "http://localhost/fineuploader/endpoint.php",
// endpoint: "http://localhost/fineuploader/endpoint.php",//commented to prove that i used //both of the relative and absolute paths
},
chunking: {
enabled: true,
concurrent: {
enabled: true
},
success: {
endpoint: "http://localhost/fineuploader/endpoint.php?done",
}
},
deleteFile: {
enabled: true,
endpoint: "http://localhost/fineuploader/endpoint.php"
},
retry: {
enableAuto: true,
showButton: true
},
form:{element:"FormId", },
callbacks: {
onError: function(id, name, errorReason, xhrOrXdr) {
alert(qq.format("Error on file number {} - {}. Reason: {}", id, name, errorReason));
},
});
答案 0 :(得分:1)
Ray Nicholus先生的回答Here很有用但我想在我的案例和我的错误中提供解决方案,我的问题是在第一页我没有在表格标签中提供行动属性我做的第二个,所以当我在第二页中提供表格的动作与
中指定的值不同let defaults = NSUserDefaults.standardUserDefaults()
defaults.setObject("Coding Explorer", forKey: "userNameKey")
请求转到action属性值path(form.php)而不是上面的请求值(endpoint.php)。
答案 1 :(得分:0)
这真的很简单,这个问题没有其他答案:你的端点不正确(当然响应也是无效的)或者你的端点是正确的,但你的端点没有返回有效的JSON。您需要仔细查看响应以确定问题。
在您的情况下,您的端点返回HTML,而不是JSON。您必须在服务器上修复此问题。