Javascript/AJAX-向google发送反向图像搜索请求
因此,我一直在尝试通过ajax执行反向图像搜索请求,但它给了我302个错误。查看firebug控制台,我发现google返回的响应头中的url将我链接到结果,但我不知道如何访问它并将另一个ajax查询发送到新位置。任何帮助都将不胜感激 这是响应标题: 这是我当前的代码:Javascript/AJAX-向google发送反向图像搜索请求,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,因此,我一直在尝试通过ajax执行反向图像搜索请求,但它给了我302个错误。查看firebug控制台,我发现google返回的响应头中的url将我链接到结果,但我不知道如何访问它并将另一个ajax查询发送到新位置。任何帮助都将不胜感激 这是响应标题: 这是我当前的代码: <form action="http://images.google.com/searchbyimage/upload" id="contactForm1" method="post" enctype="multi
<form action="http://images.google.com/searchbyimage/upload" id="contactForm1" method="post"
enctype="multipart/form-data">
<input type="hidden" name="image_url" id="image_url" />
<input type="hidden" name="btnG" id="btnG" value="Search" />
<input type="file" name="encoded_image" id="encoded_image" />
<input type="hidden" name="image_content" id="image_content" />
<input type="hidden" name="filename" id="filename" />
<input type="hidden" name="hl" id="hl" value="en" />
<input type="hidden" name="bih" id="bih" value="507" />
<input type="hidden" name="biw" id="biw" value="1920" />
<input type="button" name="submit" value="Submit" />
</form>
$(document).ready(function () {
$("form").bind("click", "input[type='button']", function () {
var formData = new FormData($("form")[0]);
$.ajax({
type: "post",
url: "http://images.google.com/searchbyimage/upload",
enctype: 'multipart/form-data',
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (text) {
console.log(text);
}
});
});
});
我想你应该试试这个:
var formData = new FormData($(this).closest("form").serialize());