Tag: ajax

删除非活动类项

我试图通过上传图像并通过创建具有新id’s新div并将class作为第一页的current添加到容器中来进行如下所示的pagination 。 如果我更改为新页面,则将活动类删除到当前页面并将其添加到所选页面。 我想知道如何删除所有没有“当前”类的inactive页面 这是我的代码: var imagesPerPage = 4, pageNumber = 1; function onAjaxSucceded(data) { var pagesContainer = $(‘#pagesContainer’), imagesInPage = 0, divPage = $(“#p1″); $.each(data.result, function(index, file) { if (imagesInPage >= imagesPerPage) { imagesInPage = 1; pageNumber += 1; divPage = $(”, {id : “p” + pageNumber}).addClass(‘pagedemo’).hide().appendTo(pagesContainer); } else { imagesInPage += 1; } […]

使用jQueryrest调用

我试图使用jQuery从以下URL获取返回的信息: Var URL = http://getdeeplink.linksynergy.com/createcustomlink.shtml?token=2e9830b7ed11c5dee96dd4b4a9e83da216c9d583ae1e617bcafdd6eb004e3c86&mid=13508&murl=http://itunes.apple.com/us/music-video/if-you-think-this-song-is/id413824018?uo=4 我已经尝试了下面概述的两种方法,但在这两种情况下,程序只运行代码块,就像没有发生任何事情一样。 谁能说出我做错了什么? $.ajax({ type: “GET”, dataType: “jsonp”, url: URL, success: function(data){ alert(data); } }); 第二种方法: $.get(URL, function(data) { alert(‘Load was performed.’); alert(data); });

contentType:’application / json’和POST方法(JavaScript)

我需要用JavaScript创建一个Web服务器客户端,我在定义Request头时遇到了一些问题。 我需要POST方法和Content-Type:“application / json”。 我试过这个: $.ajax({ url: ‘http://MyWebServiceAddress’, data: JSON.stringify({user:’user’,pass:’pass’}), type: ‘POST’, crossDomain: true, dataType: ‘json’, success: function () { alert(“success”) }, error: function (xhr, ajaxOptions, thrownError) { alert(“Error: ” + xhr.status + “\n” + “Message: ” + xhr.statusText + “\n” + “Response: ” + xhr.responseText + “\n” + thrownError); } }); 但是如果我把contentType这样: contentType:’application / […]

Ajax使用无用参数获取请求

我正在尝试执行下一个: $.ajax({ type: ‘GET’, url: ‘http://127.0.0.1:6789/dir’, data: “”, success: function(data) { /*do something*/ }, dataType: ‘html’ }); 但是当它执行时,我的服务器会收到如下内容: http://127.0.0.1:6789/dir?_32567871112 我不想传递任何参数。 我错了什么?

AJAX:JWT auth通过src进行video加载

我要求来自需要JWT网络令牌的API的video: // when the ajax call is done (the tolken is recieved ) getAccessToken.done(function(data) { var d = JSON.stringify({‘fpath’: fpath}) // get the download url var downloadurl = $.ajax({ type: “POST”, url: “https://gcp.inbcu.com/download”, beforeSend: function(xhr){ xhr.setRequestHeader(“Authorization”, “JWT ” + data.access_token); }, contentType: ‘application/json’, data: d, success: function(response){ $(‘#video-source’).attr(‘src’, response.url) $(‘#myvideo’).load() }, error:function(jqXHR, textStatus, errorThrown) { […]

根据下拉选择创建动态下拉选项 – 卡住

所以我正在尝试创建一个动态表单,其中第二个下拉框是根据第一个下拉列表填充的。 我正在使用ajax和jquery帮助在我的django项目中构建这个动态表单,我需要一点帮助。 我有一个正常工作的ajax调用,我已经将我的选择发送回表单,但现在我无法用我的选择填充表单。 有人可以帮我把json输出变成html选项吗? 这是我的ajax.py: def switch_plan(request, *args, **kwargs): from plans.models import Plan, OwnershipType, MemberType, PlanMember from datetime import datetime now = datetime.now() json = {} data = request.POST plan_type = data.get(‘plan-plan_type’) print plan_type if request.is_ajax(): if plan_type == ‘5’: ownership = OwnershipType.objects.all().exclude(id=3).exclude(id=8).exclude(id=9) json[‘owner_types’] = ownership return HttpResponse(simplejson.dumps(json), mimetype=’application/json’) 我的plans.html js代码: $(function(){ $(“#id_plan-plan_type”).change(function() { q […]

jQuery XML Ajax调用失败… FIREFOX!

这很奇怪。 我习惯于IE浏览XML格式的问题,但这是我第一次遇到Firefox问题。 在此页面上创建XML: http://www.harrahs.com/content/events/EventCalendarFeedXml.jsp?propCode=UHA&uniqueEvents=y&showTimes=y 我用来引入XML的代码是 //Read XML for Events $.ajax({ type: “GET”, url: “/content/events/EventCalendarFeedXml.jsp?propCode=UHA&uniqueEvents=y&showTimes=y”, dataType: ($.browser.msie) ? “text” : “xml”, success: function(data) { var xml; if (typeof data == “string”) { xml = new ActiveXObject(“Microsoft.XMLDOM”); xml.async = false; xml.loadXML(data); } else { xml = data; } var eventNumber = 0; $(‘event’, xml).each(function(i) { if ($(this).find(“venue”).text() […]

如何在AJAX中处理JSON输出?

我在.js文件中有这段代码片段 $(function () { // KeyDates var url = “http://localhost:8732/Design_Time_Addresses/Intel.IIP.MDF.WCF/ProgramCalendarService/GetKeyDatesCalendarNew”; $.ajax({ url: url, data: null, type: ‘POST’, contentType: ‘application/json’, dataType: ‘json’, success: function (GetKeyDatesCalendarDataNew) { alert(GetKeyDatesCalendarDataNew); $(document).ajaxStop($.unblockUI); } }); }); 如何处理GetKeyDatesCalendarDataNew中的键值对?

Spring MVC + JQuery + Ajax问题

我正在尝试使用Jquery Ajax对我的Spring MVC应用程序进行Ajax调用。 应用程序控制器工作正常,但我无法使这个Ajax测试控制器工作。 触发警报但从未对控制器进行调用。 我也尝试过使用load,get,post。 他们都没有打电话给服务器。 这让我觉得我做的事情显然是错的。 如果我将URL直接放在浏览器地址栏上,则会调用控制器。 如果有人可以指导我正确的方向或告诉我我做错了什么,我将不胜感激。 JavaScript的 function doAjax() { alert(“did it even get here?”); $.ajax({ url : “simpleRequestTest.do”, method: “GET”, success : function(response) { $(‘#show’).html(response); } }); } Simple Test Simple Test … 调节器 @RequestMapping(“/simpleRequestTest”) public @ResponseBody String performSimple() { return “Very Simple Test”; }

将值推入嵌套的ko.observableArray

我希望将供应商列表嵌入到我从服务器获得的现有JSON Payload中,具体取决于JSON Payload中的项是否需要供应商。 我最终想要的是这样的事情: { “ProductName”: “Product123”, “RequiredComponents”: “CAP 10% H/Vol”, “StockCode”: “142111411”, “RequiredQtyByBom”: 4, “QtyUnassignedInWarehouse”: 0, “QtyAllocatedInWarehouse”: 40, “PCBReference”: “442C”, “QtyOnOrder”: 26, “Vendors”: [], “RequireVendor”: false }, { “ProductName”: “Product123”, “RequiredComponents”: “Screws”, “StockCode”: “Screws”, “RequiredQtyByBom”: 1, “QtyUnassignedInWarehouse”: 0, “QtyAllocatedInWarehouse”: 14, “PCBReference”: “Screws”, “QtyOnOrder”: 26, “Vendors”: [ {“VendorID”: “3”, “VendorName”: “ABC Supplier”, “VendorMOQ”: 50000, “VendorItemPrice”: […]