jQuery的:怎么了成功:jQuery

2023-09-10 15:50:59 作者:我的孤单变成不安

<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?