jQuery的:怎么了成功: [英] jQuery: Whats up with the success:

查看:82
本文介绍了jQuery的:怎么了成功:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript"> 
var fixed = 1;
var sizew = 122; 
var sizeh = 160; 

    /*
     * function crop()
     * ajax function which returns the cropped image
     */
    function crop() {

        $.ajax({
               type: "POST",
    dataType: 'json',
               url:"functions.php?action=crop",
               data: {x: $('#x').val(),y: $('#y').val(),w: $('#w').val(),h: $('#h').val(),fname:$('#fname').val(),fixed:fixed,sizew:sizew,sizeh:sizeh},
               success: function(response){
                        alert('TEST');
                   if(!fixed)

        $("#showPhoto").css({overflow:"auto"})

                   $("#showPhoto").html($(document.createElement("img")).attr("src",response.filename)).show();
                   $("#showPhoto").after("There you go...").show();
                   $("#image").slideUp();
               }
             });
    }
    </script>

<img id="loading" src="c/assets/loading.gif" style="display:none;">
<div id="showPhoto"></div>
<div id="image" style="display:none;">

<form action="" method="post" id="crop_details">
        <input type="hidden" id="x" name="x" />
        <input type="hidden" id="y" name="y" />
        <input type="hidden" id="w" name="w" />
        <input type="hidden" id="h" name="h" />
        <input type="hidden" id="fname" name="fname"  />
        <input type="button" value="Crop Image" onclick="return crop();" />
</form>

</div>

<div id="upload">
<form id="form1" action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<input type="button" id="buttonUpload" value="Upload Image" onClick="return ajaxFileUpload();" />
</form>
</div>   

为什么犯规它警报测试当我运行的功能?它发出的AjaxCall,并获得response.filename回来,但它不运行成功的东西吗?不报警测试并没有休息。

why doesnt it alert TEST when i run the function? It send the ajaxcall, and get the response.filename back, but it doesnt run anything in success? Not the alert "test" and neither the rest..

但..它做的工作时,即时通讯不包括top.php在文件的顶部。

But.. it do work when im not including "top.php" at the top of the file.

但什么可能运行成功打断呢?

But what could possibly interrupt this from running the success?

top.php是它装载标题,头部的JavaScript和CSS文件和一些JavaScript功能

top.php is where it loads title, head javascripts and css files and some javascript functions

更新 我犯了一个错误处理程序,现在得到这个Firebug的:

UPDATE I made a error handler, and now get this in Firebug:

get channel   "({"filename":"1283548305.jpg"})"(RED)
get statusText   "OK"(RED)
getResponseText  "({"filename":"1283548305.jpg"})"(RED)
constructor(RED)  function()

(红色),表示该文本是红色..像多数民众赞成的错误,我认为。

(RED) means that the text is red.. like thats the error i think.

推荐答案

检查 response.status ,什么是它的价值呢?

Check response.status, what is its value?

这篇关于jQuery的:怎么了成功:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆