这可能是一个愚蠢的错误,但我正在使用JQuery ajax来对付PHP后端,我希望PHP脚本将进度发布回网页.
它看起来工作正常,但我无法获得e.target.responseText的内容.
如果我执行console.log(e.target),我会在控制台中获取XMLHttpRequest对象.我可以看到responseText:"1 av 1500 linjer"
但是,如果我执行console.log(e.target.responseText),它就是空的.
我迷失了吗?
这是我的功能:
$.ajax(
{
type: "POST",
url: "modEcs/ajax/ecs.php?a=analyseExcel",
processData: false,
contentType: false,
xhrFields:
{
onprogress: function(e)
{
console.log(e.target);
console.log(e.target.responseText);
}
},
success: function(data)
{
},
error: function (xhr, ajaxOptions, thrownError) { alert(xhr.statusText); }
});
Run Code Online (Sandbox Code Playgroud)
控制台中的数据:
XMLHttpRequest
onabort: null
onerror: null
onload: null
onloadend: null
onloadstart: null
onprogress: function(e)
onreadystatechange: null
ontimeout: null
readyState: 4
response: "1 av 1500 linjer"
responseText: "1 av 1500 linjer"
responseType: ""
responseURL: "xxx"
responseXML: null
status: 200 …Run Code Online (Sandbox Code Playgroud) 我不太明白Twig中的属性函数是如何工作的.有人可以帮我举个例子吗?
我在SQL中有一个名为dynamic的字段.我可以是例如"field27",但我不知道号码,号码保存在radio.id中.我想这样做:
{% for radio in gruppeType.radios %}
<td><!-- value of "field" + radio.id--></td>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
如何使用field + radio.id作为twig-variable的名称?
当我将表单发布到jQuery AJAX时,我突然盯着在Safari中收到400 Bad request错误.我觉得这很奇怪,因为它已经工作了2到3年了,它仍然在Firefox中运行.我不知道从哪里开始调试,有人可以帮助我吗?
submitHandler: function()
{
var formElement = document.getElementById("frmBanner");
var bannerfil = new FormData(formElement);
bannerfil.append("gruppe412", $('#gruppe412').val() );
$.ajax(
{
type: "POST",
url: "/modContent/ajax/banner-copy.php?a=frmBanner&type=45",
data: bannerfil,
dataType: "html",
processData: false,
contentType: false,
success: function(data)
{
if( data.length > 10 )
$("#content").html( data );
else
location.href="#modContent/ajax/" + data;
},
error: function (xhr, ajaxOptions, thrownError) { alert(xhr.statusText); }
});
return false;
},
// Do not change code below
errorPlacement : function(error, element) {
error.insertAfter(element.parent());
}
}
Run Code Online (Sandbox Code Playgroud)