Я создаю программу php, чтобы получить 3 переменные с веб-сайта и вычислить их, а затем опубликовать результат, я могу прочитать переменные, рассчитать их, но часть публикации трудна для меня, потому что она использует форму Ajax (Я думаю) возможно ли размещение с php с использованием XMLhttprequest?
это кнопка отправки:
<a href="#" class="formSubmit" tabindex="3">
это окно сообщения:
<textarea name="message" id="messageContent" rows="18" wrap="virtual" tabindex="2"></textarea>
Я пытался обработать его как обычную форму, но это не такне работает, я выследил функцию ajax, чтобы отправить:
function formSubmitFunction(e,action, target){
e.stopPropagation();
e.preventDefault();
if ($("#messageContent").attr("value") == undefined || $("#messageContent").attr("value").length < 2){
alert("A mensagem precisa ter no mÃnimo 2 caracteres.");
$("#messageContent").focus();
return false;
}else {
$("#formSubmit").html('<img src="http://website.com/'+desTheme+'/images/send_post.gif');
if(action == "post"){
$("#formAjax").append('<div id="carregando"></div>');
PostFunctions.insertPost(topicId,$("#messageContent").val(), callbackInsertPost);
} else {
var postId = target.replace("#","");
$("#formAjax").append('<div id="carregando"></div>');
PostFunctions.editPost(postId,$("#messageContent").val(), callbackEditPost);
}
return false;
}
}
help
@ edit:
нашел другую функцию insertPost
function callbackInsertPost(response){
var result = eval("("+response+")");
if($("#popup").length){
$("#popup").remove();
}
if(!result.error){
var returnMessage = "";
if(result.isForumModerated){
returnMessage = '<div id="popup" class="autoClear simple">'
+'Sua mensagem está aguardando a aprovação da moderação.'
+'</div>';
$("#carregando").remove();
$(actualPostId).prepend(returnMessage);
window.setTimeout(function(){
$("#popup").fadeOut("slow", function(){
$("#popup").remove();
});
},5000);
$("#formAjax").remove();
} else {
//console.log(result);
window.setTimeout(function(){
document.location = "_t_lastpost_"+topicId+"_"+forumId+"?postId="+result.postId;
},1500);
/*returnMessage = '<div id="popup" class="autoClear simple">'
+'Mensagem enviada com sucesso! Clique neste <a href="_t_lastpost_'+topicId+'_'+forumId+'">link</a> para ver sua mensagem'
+'</div>';*/
}
} else {
if(result.nickname_reproved){
document.location = "changenickname.jbb";
} else {
$("#carregando").remove();
for(i = 0; i < result.messages.length; i++){
$("#formAjax").prepend('<div id="popup" class="autoClear error-post">'
+result.messages[i]+'<br/>'
+'</div>');
}
$.scrollTo("#popup",500);
$("#formSubmit").html('<a href="#" class="formSubmit" tabindex="3"><img src="'+baseImages+'/themes/'+desTheme+'/images/pm_send.gif"/></a>');
$(".formSubmit").bind("click",function(e){
formSubmitFunction(e,"post")
});
}
}
}
@ edit2:
PostFunctions.insertPost = function(p0, p1, callback) {
DWREngine._execute(PostFunctions._path, 'PostFunctions', 'insertPost', p0, p1, callback);
}