English 中文(简体)
• 如何在AJAX中将吉大港定居区的头脑膜炎成像型jpeg/png 更新帽子时?
原标题:How to set HTTP header img-type jpeg/png in AJAX when updating captcha?

Use jquery + php. Doing Customs AJAXcaptcha. i. 用户点击图像,自动更新。

<script src="/js/jquery.js"></script>

<script>

$(document).ready(function(){

    $.post( /captcha.php , {}, function(resp){

        $("div").html(resp);

    });

});

</script>

<div></div>

in PHP header already sent, so if it includes into <img src="/captcha.php" /> it prints captcha in jpeg. The problem seem to be is header that need to be sent. So, how can i do this? The header is sent in PHP. It doesnt work in js.

最佳回答

如果你想在一份超文本文件中改变形象,那么就会改变形象的陈词(或用新的文字取代图像内容)。 Don tuse XMLHttpRequest at all.

问题回答

Add header function in Youcaptcha.php file:

header( Content-Type: image/jpeg );

如果你装上另一个字母的来源。 然后,你可以简单地通过显示价值发送文件src。 这样,captcha.php 法典就象这样变成了。

 $source="/path/to/the/file.jpg";
 header("Content-type:text/plain");
 print $source;

当你收到时,你可以做以下工作来改变来文方。

$("#changeCaptchaButton").click(function() {
  $.ajax({
    url: "captcha.php",
    cache: false,
    success: function(data) {
        alert("changing source of image");
        var source=data;
        $("#captchaImg").attr("src", source); 

      }
   });
});

如果您在上做了改动,请在<>现时>上填写。 然后不使用ja,而是使用后者的 j脏方法。





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签