normally my ajax functions look something like this:
通常我的ajax函数看起来像这样:
function ajaxCallback(url,functionToRun)
{
if (window.XMLHttpRequest)
{// code for new browsers
myXMLlhttp=new XMLHttpRequest();
}
else
{// code for IE6 and lower
myXMLlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
myXMLlhttp.onreadystatechange=functionToRun;
myXMLlhttp.open("POST",url,true);
myXMLlhttp.send();
}
function getItemList(rep, sort_by_column, order_by)
{
ajaxCallback("scripts/get_item.php?rep="+ rep + "&sort_by_column=" + sort_by_column + "&order_by=" + order_by,function()
{
if (myXMLlhttp.readyState==4 && myXMLlhttp.status==200)
{
document.getElementById("main_area").innerHTML=myXMLlhttp.responseText;
}
});
}
I would like to somehow submit a form on that page using ajax, I looked at some tutorials / questions but they all suggest JQuery, but is there a way to include that form as a variable Or another way of submitting it, without jQuery? I can find a way around it, but I thought I'd check to see if there was some simple way of doing it.
我想以某种方式使用ajax在该页面上提交表单,我查看了一些教程/问题,但他们都建议使用JQuery,但是有没有办法将该表单作为变量包含或者提交它的另一种方式,没有jQuery?我可以找到解决方法,但我想我会检查是否有一些简单的方法。
1 个解决方案
#1
1
Pure JavaScript solution would be
纯JavaScript解决方案将是
document.getElementById('formid').submit();
or
要么
document.formname.submit();
EDIT: You should add a JavaScript tag to your question and remove the "php" tag. It really doesn't have anything to do with PHP.
编辑:您应该在您的问题中添加JavaScript标记并删除“php”标记。它与PHP没有任何关系。
#1
1
Pure JavaScript solution would be
纯JavaScript解决方案将是
document.getElementById('formid').submit();
or
要么
document.formname.submit();
EDIT: You should add a JavaScript tag to your question and remove the "php" tag. It really doesn't have anything to do with PHP.
编辑:您应该在您的问题中添加JavaScript标记并删除“php”标记。它与PHP没有任何关系。