小编mic*_*ael的帖子

Ajax成功和错误功能失败

我无法让我的jQuery ajax正常工作.它指向PHP页面以更新数据库,但永远不会返回脚本以获取成功或错误选项.

我的代码如下:

$(document).ready(function(){  
        $("form#updatejob").submit(function() {  
            function textreplace(x) {return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");}
            // we want to store the values from the form input box, then send via ajax below
            var job     = $("#job").attr("value");
            var description     = $("#description").val();
            description.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
            var startDate   = $("#startDate").attr("value");
            var releaseDate = $("#releaseDate").attr("value");  
            var status  = $("#status").attr("value"); 
            $.ajax({
                beforeSend:textreplace(description),
                type: "POST",  
                url: "updatedjob.php",
                data: "jobID="+ job +"& description="+ description +"& startDate="+ startDate +"& releaseDate="+ releaseDate +"& status="+ status, 
                success: function(){  
                    $("form#updatejob").hide(function(){$("div.success").fadeIn();});  
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) { …
Run Code Online (Sandbox Code Playgroud)

ajax jquery

41
推荐指数
3
解决办法
30万
查看次数

用于动态id的JQuery Selector

我正在尝试更改Jquery中的图像源

<a href="" class="wanted" id="'.$status_id[$num].'"><img src="/images/wanted.png">
Run Code Online (Sandbox Code Playgroud)

通过JQuery选择器:

$(".wanted "+ id).attr("src", '/images/wanted_.png');
Run Code Online (Sandbox Code Playgroud)

idjavascript中定义的地方是php变量$status_id[$num].我第一次尝试使用$(this)无济于事.任何见解都会有所帮助.

jquery

5
推荐指数
2
解决办法
3万
查看次数

标签 统计

jquery ×2

ajax ×1