Tag: ajax

jQuery ajax上传进度条 – 没有闪存

我正在寻找一个类似于uploadify的文件上传器 ,其进度条不依赖于flash,最好使用jQuery – 这可能吗?

如何使JQuery-AJAX请求同步

如何使ajax请求同步? 我有一张需要提交的表格。 但只有在用户输入正确的密码时才需要提交。 这是表单代码: 并且用于发送和检查密码的jquery代码是这样的: var ajaxSubmit = function(formE1) { var password = $.trim($(‘#employee_password’).val()); $.ajax({ type: “POST”, async: “false”, url: “checkpass.php”, data: “password=”+password, success: function(html) { var arr=$.parseJSON(html); if(arr == “Successful”) { return true; } else { return false; } } }); } 但是,无论ajax请求返回的值如何,表单始终都会提交。 我检查了其他一切。 当输入正确的密码时,arr的值将变为“成功”,反之亦然。 如何使此请求同步? 就我可以调试而言,请求是异步的,因此在请求完成之前提交表单。 checkpass.php的代码 setbyid_employee(1); $arr=$m->editdisplay_employee(); if($arr[’employee_password’] == $employee_password) { […]

JQuery AJAX使用SOAP Web服务

我一直在尝试并尝试学习JQuery,使用AJAX来使用我之前写过的SOAP Web服务。 以下是我使用的代码: var webServiceURL = ‘http://local_server_name/baanws/dataservice.asmx?op=GetAllCategoryFamilies’; var soapMessage = ‘</soap12:Envelope'; function CallService() { $.ajax({ url: webServiceURL, type: "POST", dataType: "xml", data: soapMessage, contentType: "text/xml; charset=\"utf-8\"", success: OnSuccess, error: OnError }); return false; } function OnSuccess(data, status) { alert(data.d); } function OnError(request, status, error) { alert('error'); } $(document).ready(function() { jQuery.support.cors = true; }); 目前,在Web服务中调用的方法返回包含类别代码和类别描述的类别系列数组。 由于该方法返回XML,因此我相应地设置了ajax查询。 […]

如何在表单中的输入类型=“文件”中添加图像并在同一表单上提交它们之后生成缩略图图像

我有一个允许用户上传图片的表格。 在用户提交表单后,我想在前端生成每张图片的缩略图,然后将其存储在服务器上。 出于安全原因,无法更改文件输入字段的值,因此如何向服务器发送在js中在前端生成的一些缩略图图像? 在表单提交之前,是否可以在前端从输入文件字段中的图像集生成缩略图? 然后同时提交两个?

返回JsonResult与MVC控制器中的对象列表

我的MVC控制器中有一个简单的方法: [HttpPost] public JsonResult GetAreasForCompany(int companyId) { var areas = context.Areas.Where(x => x.Company.CompanyId == companyId).ToList(); return Json(areas); } 这是一个区域对象: public class Area { public int AreaId { get; set; } [Required] public string Title { get; set; } public bool Archive { get; set; } public virtual Company Company { get; set; } } 这就是我从视图中调用方法的方式: […]

返回AJAX调用数据的JavaScript函数

我想创建一个JavaScript函数,它返回jQuery AJAX调用的值。 我想要这样的东西。 function checkUserIdExists(userid){ return $.ajax({ url: ‘theurl’, type: ‘GET’, cache: false, data: { userid: userid }, success: function(data){ return data; } }); } 我知道我可以通过将async设置为false来实现此目的但我宁愿不这样做。

jQuery发布到Rails

我的设置:Rails 3.0.9,Ruby 1.9.2,jQuery 1.6.2 我有一个表单,为用户显示多张照片和评论,我希望实现内联评论。 Summer 2011 Write a commenthttps://stackoverflow.com/questions/7237720/jquery-post-to-rails/… Seeing a movie Write a commenthttps://stackoverflow.com/questions/7237720/jquery-post-to-rails/… 我想在用户点击textarea字段中的回车键时提交一个AJAXpost。 这是我到目前为止的javascript(不完整) $(‘#newsfeed’).delegate(‘.comment_box’, ‘keydown’, function (event){ event.preventDefault(); $.post(‘/sub_comments’, https://stackoverflow.com/questions/7237720/jquery-post-to-rails/…); }); 我正在使用delegate方法,因为 内容可以用另一个AJAX调用替换。 我需要的是jQuery post方法的语法,假设我需要传递一些forms参数,比如说photo_id等等。假设我有办法访问params的值,那么post调用创建params的语法是什么Rails期待他们 这是标准的Rails位 sub_comments_controller.rb def new @sub_comment = SubComment.new respond_to do |format| format.html # new.html.erb format.js end end 另外我不想使用通常的 true) do |f| %> true) do |f| %>我可以添加的每个内联评论。 […]

jQuery:同时发出ajax请求,有可能吗?

我正在使用jQuery同时尝试检索多个数据。 要求的背景是不同的数据位需要不同的时间才能变得可用,因此我希望在返回时显示每个部分。 问题是请求似乎“排队”; 下一个请求在前一个请求返回之前不会发生。 经过广泛阅读后,似乎选择’async:false’可能就是我所追求的,但这似乎没有任何区别。 从TCP / IP调试我可以看到浏览器不会启动多个连接; 它在先前请求返回时使用相同的连接。 我在我的时间里看到很多网站同时在ajax上加载数据,所以很明显它是可能的,但是我正在试图让它发挥作用。 这是我的代码: $.ajax({ type: “GET”, async: false, url: “foo1.php” }); $.ajax({ type: “GET”, async: false, url: “foo2.php” }); $.ajax({ type: “GET”, async: false, url: “foo3.php” });

通过ajax post将文件与表单数据一起发送

我正在尝试通过ajax上传文件以及表单中的某些字段。 但是,它不起作用。 我收到这个错误。 未定义的索引: – 文件 这是我的代码。 HTML Upload Software / File Price($) 阿贾克斯 $(“#add_product”).click(function(e){ e.preventDefault(); product_name = $(“product_name”).val(); //d = $(“#add_new_product”).serialize(); $.ajax({ type: ‘POST’, url: ‘ajax.php’, data: $(“#add_new_product”).serialize(), success: function(response) { // alert(response); } }) }); PHP if (0 < $_FILES['file']['error']) { echo ":!"; } else { echo "ASa"; } 我在这里想念的是什么?

jquery AJAX和json格式

我有一个期望接收json的web服务,如下所示: {“first_name”:”test”,”last_name”:”teste”,”email”:”moi@someplace.com”,”mobile”:”+44 22 2222 2222″, “password”:”testing”} 我在jquery中调用ajax: $.ajax({ type: “POST”, url: hb_base_url + “consumer”, contentType: “application/json”, dataType: “json”, data: { first_name: $(“#namec”).val(), last_name: $(“#surnamec”).val(), email: $(“#emailc”).val(), mobile: $(“#numberc”).val(), password: $(“#passwordc”).val() }, success: function(response) { console.log(response); }, error: function(response) { console.log(response); } }); 有没有办法检查我的数据发送格式? 我应该没有向服务器发送正确的JSON(这是validation的第一步)。 我的jquery代码是发送有效的JSON还是我错过了什么?