javascript和ajax

以下是为您整理出来关于【javascript和ajax】合集内容,如果觉得还不错,请帮忙转发推荐。

【javascript和ajax】技术教程文章

javascript – 从ajax调用中对动态HTML应用猫头鹰轮播【代码】

我需要将一个猫头鹰轮播及其所有CSS应用于来自ajax调用的动态HTML元素. 目前,代码如下所示:jQuery(function ($) {$('.entry-content').addClass('entry-content--quiz')$('.get-questions').on('click', function (e) {e.preventDefault();let url = $(this).attr('href');$.ajax({url: url,}).done(function (data) {$('.entry-content').html(data);$('#wpvq-page-0').owlCarousel({items:1,slideBy: 1,stagePadding: 0,nav: tr...

javascript – Ajax中的多个成功函数【代码】

我正在使用Ajax脚本从我的数据库中获取数据并将其发布到多个文本框中.发布数据后,我还想用文本框计算. 当我运行脚本时,我看到该脚本同时运行所有计算.有人知道如何在我的脚本中构建多个onSuccess函数,以便脚本按正确的顺序执行代码吗? 这是我的脚本:$(document).on('change', '[id^=vat1]', function getVat12() { // Do an Ajax request to retrieve the product price console.log("getVat2 before ajax", jQuery('#vat1').val...

javascript – Ajax字符串长度限制?【代码】

可以添加到ajax的url的参数长度是否有限制?我在Ruby上使用Thin服务器,并以这种格式从Web浏览器发出ajax请求:io=new XMLHttpRequest(); io.open("GET","http://localhost:3000&v="+encodeURIComponent(JSON.stringify(v)),true);当字符串v的长度超过大约7000字节时,它似乎崩溃了.当更少时,似乎工作.我的观察是对的吗?限制来自哪里?从Thin,Javascript还是浏览器?我使用谷歌Chrome浏览器.解决方法:Is there a limit to the lengt...

javascript – 在ajax调用中填充Vue.js中的下拉列表【代码】

我希望能够进行ajax调用并使用返回的结果生成使用vue.js的下拉列表选项.我可以做这个:<select v-model="selected"><option v-for="option in options" v-bind:value="option.value">{{ option.text }}</option> </select> <span>Selected: {{ selected }}</span>.js文件new Vue({el: '...',data: {selected: 'A',options: [{ text: 'One', value: 'A' },{ text: 'Two', value: 'B' },{ text: 'Three', value: 'C' }]} })但我不想让...

javascript – AJAX延迟下一行的执行【代码】

鉴于以下代码,任何人都可以帮助我理解为什么在第二个警报之后执行第一个警报?我相信这是因为ajax有一个很小的延迟,直到它取出数据,如果我错了,请纠正我.谢谢你提前.Javascript code:window.onload = function() { arry = new Array(); jQuery.ajax({ type: "GET",url: "index.php?op=17&id=@@postID@@&action=fetch", dataType: "text",success: function(response){ var e = response;console.log(JSON.parse(e));arry =...

javascript – 在AJAX请求后刷新jQuery代码【代码】

例如,假设我有一些按钮在单击时调用AJAX请求.$(document).ready(function(){$('button').each( function() {$(this).click( function() {alert('Clicked.');// ...AJAX request...});}); });当我点击一个按钮时,一切正常. 但是如果我用AJAX请求加载按钮然后点击它们,上面的代码就会停止工作. 我怎么能摆脱这个? 我试过了on()方法$(document).ready(function(){$('button').each( function() {$(this).on('click', function() {ale...

javascript – Ajax轮询聊天在快速聊天时在消息接收器前端获得重复【代码】

我使用以下方法开发了一个javascript聊天(后端的php):1) long-polling to get new messages for the receiver 2) sessionStorage to store the counter of messages 3) setInterval to read new messages and if sessionStorageCounter < setIntervalCounter then the last message is shown to receiver. 4) javascript to create,update and write the chat dialogues该模块工作正常,但当用户快速聊天时,接收者的前端会收到两...

javascript – $.ajax vs $.post:获取允许来源错误【代码】

使用这个做ajax很好:$.post("http://localhost:3000/scrape",{data: json},function(data, status){});但这不是?$.ajax({type: 'POST',url: 'http://localhost:3000/scrape',data: json,contentType: "application/json",success: function(data,status){},async:false});使用$.ajax我得到了错误XMLHttpRequest无法加载http://localhost:3000/scrape.对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Al...

javascript – 通过ajax登录和注册是否安全?【代码】

我的JS代码(例如,可能存在一些语法错误)$(document).on('click','#btnEdit',function(e){ var id = $("#inp_id").val(), ps = $("#inp_ps"); $.ajax({type: 'POST',url: 'http://example.php',data: {act:'#LogIn',id:id,ps:ps},success: function(response){if($.trim(response) === "success"){alert("Login Successful"); }else{alert("Invalid ID or Password");}}}); });在PHP里面if($_POST[act] == "#LogIn"){$userid ...

Javascript / AJAX在Opera中不起作用,在FF / IE / Chrome中运行完美【代码】

我目前在名为getresults.js的文件中有这个Javascript:function getItems(str) { if (str==""){document.getElementById("getItems").innerHTML="";return;} if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();} else{// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhtt...