Javascript jquery.form获取普通HTML
我试图在插件jquery.form.js()中获得简单的HTML作为响应,但我无法获得它。因此,我的代码如下所示:Javascript jquery.form获取普通HTML,javascript,php,jquery,ajax,jquery-plugins,Javascript,Php,Jquery,Ajax,Jquery Plugins,我试图在插件jquery.form.js()中获得简单的HTML作为响应,但我无法获得它。因此,我的代码如下所示: print "$('#filter_form').ajaxForm({ target:'#ajax1', beforeSend: function() { console.log('Image uploading started.'); img_status.fadeOut(); img_slider.width(
print "$('#filter_form').ajaxForm({
target:'#ajax1',
beforeSend: function() {
console.log('Image uploading started.');
img_status.fadeOut();
img_slider.width('0%');
img_percent_text.html('0%');
},
uploadProgress: function(event, position, total, percentComplete) {
console.log('Image upload update...');
img_slider.width(percentComplete + '%');
img_percent_text.html(percentComplete + '%')
},
complete: function(responseText, statusText, xhr) {
img_slider.width('100%');
img_percent_text.html('100%')
console.log('Image uploading finished!');
img_preview.fadeOut(800);
alert(responseText);
}
});";
print "});";
print '</script>';
<form action="example.com" method="post" ></form>
因此,问题是:
如何在完整函数中获取普通HTML(responseText返回对象)
如何修复我通过ajax发送的post参数?您还可以将响应文本/html对象附加到一些html实体,例如
$('#my_id').html(responseText);
<div id='my_id'></div>
$('my#u id').html(responseText);
请注意,如果传入空数组(),empty
函数将返回FALSE
因此,如果您制作一篇没有字段(参数)的文章,那么空($\u POST)
返回FALSE
如果要检查请求是否为POST类型,请检查是否使用
isset($\u POST)
方法或$\u服务器['request\u method']=='POST'
设置了$\u POST变量,因此我的错误如下:
1.如何以普通HTML格式获取响应
responseText是包含responseText的对象
Just use responseText.responseText\
我是如何发现的:
我曾经
要在浏览器控制台中输出对象,我发现源代码位于responseText中
Just use responseText.responseText\
2.post方法的问题
我知道这个插件从表单中获取方法,所以有两个修复方法-使用param强制它
type: 'POST'
在
或者简单地将form方法设置为post,如下所示:
print "$('#filter_form').ajaxForm({
target:'#ajax1',
beforeSend: function() {
console.log('Image uploading started.');
img_status.fadeOut();
img_slider.width('0%');
img_percent_text.html('0%');
},
uploadProgress: function(event, position, total, percentComplete) {
console.log('Image upload update...');
img_slider.width(percentComplete + '%');
img_percent_text.html(percentComplete + '%')
},
complete: function(responseText, statusText, xhr) {
img_slider.width('100%');
img_percent_text.html('100%')
console.log('Image uploading finished!');
img_preview.fadeOut(800);
alert(responseText);
}
});";
print "});";
print '</script>';
<form action="example.com" method="post" ></form>
如何在JSFIDLE中测试表单,我在responseText返回[object object]中没有看到PHP选项,我已经尝试过了,div中的代码保持不变。结果是,在这个对象中有另一个responseText,当我键入responseText.responseText时,它确实正确显示了输出,但是post查询是错误的,我再次使用它,因为表单操作会导致表单所在的页面,因此如果没有post查询,我将打印表单,如果有,我只处理提交的post参数。我将尝试isset()…好的,我只是想指出,当您发表一篇没有参数的文章时,if语句将不起作用。但是,如果您希望始终具有参数,那么这应该不是问题。谢谢,我将使用REQUEST\u方法:)