当前位置:知识问问>生活百科>求raw-011代码

求raw-011代码

2024-09-14 16:34:20 编辑:join 浏览量:553

求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.zhshwenwen.com/life/378932.html
热门文章