我有一个名称orderproductForm和未定义输入数量的表单.
我想做一些jQuery.get或ajax或类似的东西,它会通过Ajax调用页面,并发送表单的所有输入orderproductForm.
我想有一种方法可以做类似的事情
jQuery.get("myurl",
{action : document.orderproductForm.action.value,
cartproductid : document.orderproductForm.cartproductid.value,
productid : document.orderproductForm.productid.value,
...
Run Code Online (Sandbox Code Playgroud)
但是我并不完全知道所有表格输入.是否有功能,功能或其他东西只发送所有表单输入?
我在我的网站上实现了一个Ajax请求,我从一个网页调用端点.它总是返回200 OK,但jQuery执行错误事件.我尝试了很多东西,但我无法弄清楚问题.我在下面添加我的代码:
var row = "1";
var json = "{'TwitterId':'" + row + "'}";
$.ajax({
type: 'POST',
url: 'Jqueryoperation.aspx?Operation=DeleteRow',
contentType: 'application/json; charset=utf-8',
data: json,
dataType: 'json',
cache: false,
success: AjaxSucceeded,
error: AjaxFailed
});
function AjaxSucceeded(result) {
alert("hello");
alert(result.d);
}
function AjaxFailed(result) {
alert("hello1");
alert(result.status + ' ' + result.statusText);
}
Run Code Online (Sandbox Code Playgroud)
JqueryOpeartion.aspxprotected void Page_Load(object sender, EventArgs e) {
test();
}
private void test() {
Response.Write("<script language='javascript'>alert('Record Deleted');</script>");
}
Run Code Online (Sandbox Code Playgroud)
("Record deleted")成功删除后我需要字符串.我可以删除内容,但我没有收到此消息.这是正确的还是我做错了什么?解决这个问题的正确方法是什么?
我正在使用rails中的ajax请求创建一个聊天,我正试图让div滚动到底部而没有太多运气.
我在这个div中包装一切:
#scroll {
height:400px;
overflow:scroll;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让它默认使用JS滚动到底部?
有没有办法让它在ajax请求后滚动到底部?
我可以使用以下jQuery代码使用Ajax请求的post方法执行文件上载吗?
$.ajax({
type: "POST",
timeout: 50000,
url: url,
data: dataString,
success: function (data) {
alert('success');
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
如果可能,我是否需要填写"数据"部分?这是正确的方法吗?我只将文件发布到服务器端.
我一直在谷歌搜索,但我发现是一个插件,而在我的计划中,我不想使用它.至少目前.
有没有什么方法可以在我的jQuery AJAX错误消息中显示自定义异常消息作为警报?
例如,如果我想通过Struts by 在服务器端抛出异常throw new ApplicationException("User name already exists");,我想在jQuery AJAX错误消息中捕获此消息('用户名已存在').
jQuery("#save").click(function () {
if (jQuery('#form').jVal()) {
jQuery.ajax({
type: "POST",
url: "saveuser.do",
dataType: "html",
data: "userId=" + encodeURIComponent(trim(document.forms[0].userId.value)),
success: function (response) {
jQuery("#usergrid").trigger("reloadGrid");
clear();
alert("Details saved successfully!!!");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
在第二个警报,我警告抛出的错误,我得到undefined,状态代码是500.
我不确定我哪里出错了.我该怎么做才能解决这个问题?
我正在尝试将数据从表单发送到数据库.这是我正在使用的表单:
<form name="foo" action="form.php" method="POST" id="foo">
<label for="bar">A bar</label>
<input id="bar" name="bar" type="text" value="" />
<input type="submit" value="Send" />
</form>
Run Code Online (Sandbox Code Playgroud)
典型的方法是提交表单,但这会导致浏览器重定向.使用jQuery和Ajax,是否可以捕获所有表单的数据并将其提交给PHP脚本(例如,form.php)?
如何使函数等到所有jQuery Ajax请求在另一个函数内完成?
简而言之,我需要等待所有Ajax请求在执行下一个之前完成.但是怎么样?
我曾经梦想过chrome(开发者频道)实现了一种通过javascript(路径,而不是域)更新地址栏的方法,而无需重新加载页面,或者他们确实已经这样做了.
但是,我找不到我认为我读过的文章.
我是疯了还是有办法做到这一点(在Chrome中)?
ps我不是在谈论window.location.hash,et al.如果上述情况存在,那么这个问题的答案将是不真实的.
在我的AJAX调用中,我想将一个字符串值返回给调用页面.
我应该使用ActionResult还是只返回一个字符串?
ajax ×10
javascript ×8
jquery ×6
post ×2
actionresult ×1
asp.net ×1
asp.net-mvc ×1
file-upload ×1
forms ×1
html ×1
json ×1
php ×1
submit ×1