当前位置:回答三>百科问答>求raw-011代码

求raw-011代码

2024-07-02 05:40:43 编辑:join 浏览量:547

求raw-011代码

代码如下:

$(document).ready(function(){

//alert("ok, guys.");

$("#addblog_form").submit(function(){return false;});

$("#s_btn").click(submitBlog);

});

function submitBlog()

{

var b = isInputRight();

if(!b)

{

alert("input is not correct.");

return;

}

//////////////////<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>

////// should be very carefull with the following line that you should have one space before the ":", or it won't work.

var data = $("#addblog_form :input").serializeArray();

//$.post($("#addblog_form").attr("action"), data, handleResp, "json");

$.ajax({

type: 'POST',

url: $("#addblog_form").attr("action"),

data: data,

success: handleResp,

error: handleErr,

dataType: 'json'

});

//alert("post go on ...");

}

function handleResp(json)

{

alert(json.message);

if(json.status == "fail")

{

}

else if(json.status == "success")

{

clearInput();

}

}

function handleErr()

{

alert("error when ajax.");

}

function clearInput()

{

$("#t_title").val("");

$("#t_blog").val("");

}

function isInputRight()

{

var title = $("#t_title").val();

if(title == "")

return false;

var blog = $("#t_blog").val();

if(blog == "")

return false;

return true;

}

标签:raw,代码

版权声明:文章由 回答三 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.huidasan.com/answer/150783.html
热门文章