Tag: ajax

MVC 4.5 Web API请求不起作用

我在.Net中设计了一个MVC 4.5 Web API。 HTTP请求必须来自Jquery AJAX Call。 在进行调用(POST)后,我在控制台中收到以下错误。 任何人都可以帮我确定我做错了什么吗? OPTIONS http://192.168.xx.xx:1245/api/values 405 (Method Not Allowed) jquery-1.7.1.min.js:4 OPTIONS http://192.168.xx.xx:1245/api/values Invalid HTTP status code 405 jquery-1.7.1.min.js:4 XMLHttpRequest cannot load http://192.168.xx.xx:1245/api/values. Invalid HTTP status code 405

jquery ajax给所有div都给出了相同的结果

我试图能够重命名文件。 在其工作的时刻,但例如,让我说我有: 文件名是’hello’,文件名是’bye’,文件三名是’嘿’ 我将文件一重命名为’something’它将重命名它,但如果我然后将文件二重命名为’youarecool’它将重命名文件一和二。 这是我的javascript,我做错了什么。 这是我的jsfiddle。 http://jsfiddle.net/RSvre/ 这是每个文件的html filename filesize | downloads Downloads | Uploaded on date 这是javascript $(‘.edit’).click(function(e){ e.preventDefault(); var auth = $(this).attr(‘id’); var each = $(this).closest(‘.each_file’).find(‘.fnl’); $.post( “ajax/edit_filename.php”, { auth:auth }) .done(function( data ) { $( “#dialog” ).dialog({ modal: true, resizable: false, title: ‘Edit file name’, buttons: { “Close”: function() { $(this).dialog(“destroy”); $(this).dialog(“close”); […]

文本框类的JQuery on Change事件在chrome中不起作用

我有一类文本框,并尝试将onChange事件附加到类。 下面的代码工作,我在Firefox中获得calData的输出,但在Chrome上不起作用 enter code here Week 1 – Week 2 – //Javascript var Test = { init: function(config) { this.bindEvents(); }, bindEvents: function() { this.config.clTest.on(‘change’,this.calData); }, calData: function(){ console.log(“calculating”); }, }; Test.init({ clTest: $(‘.test_class’), });

使用Jquery传递带参数的链接

我有这个链接: # 我想通过Jquery传递它,因此页面不会刷新。 但是,我很难实现这一目标。 我用Jquery尝试过的所有点击事件和ajax都没有成功。 基本上,我希望ajax发送delete.php iid参数中的值。

jQuery .ajax调用从不调用方法

在这篇SOpost中,我学会了如何从AJAX调用中获取返回值: function CallIsDataReady(input) { $.ajax({ url: “http://www.blah.com/services/TestsService.svc/IsDataReady”, type: “GET”, contentType: “application/json; charset=utf-8”, data: input, dataType: “json”, success: function (data) { if (!data) { setTimeout(function (inputInner) { CallIsDataReady(inputInner); }, 1000); } else { //Continue as data is ready callUpdateGrid(input); } } }); } $(document).ready(function () { var input = { requestGUID: “” }; CallIsDataReady(input); }); 此函数调用其Web服务,确实返回true。 […]

在jQuery / Coffeescript中延迟ajax调用

这是一些粗略的javascript / jquery / coffeescript,在延迟后会在页面下部的DIV中滑动。 我正在使用rails,因此我也会点击一个端点,该端点会为特定幻灯片增加数据库中的视图计数器。 jQuery -> $(“div[data-slide=’true’]”).delay(20000).animate({opacity: 1,right:’+=350′},1350, ‘swing’); id = $(“div[data-slide=’true’]”).data(“slide-id”) $.ajax({url: “http://localhost:3000/firefly/slides/” + id + “/increment”, type: “post”}); $(“div[data-close=’true’]”).click -> $(“div[data-slide=’true’]”).clearQueue().animate({opacity: 0,right:’-=350′},500, ‘easeOutBounce’); 我知道这不是最好的javascript,我真的是JS的新手 – 但我现在的问题是我无法弄清楚如何延迟ajax调用所以它只会在幻灯片播放时点击端点动画。现在,当DOM完成加载时,它会到达终点并递增计数器。

MVC 4 Ajax请求 – 引用javascript文件

我正在进行一些ajax调用以返回一些部分视图,这些视图在视图中编写脚本时工作正常。 脚本代码是 $.ajax({ url: “@(Url.Action(“ProjectPartial”, “Project”))”, contentType: ‘application/html; charset=utf-8’, type: ‘POST’, dataType: ‘html’, data: { documentType: $(‘#DocumentType’).val(), sectionName: $(‘#SectionName’).val() } }) .success(function (result) { // Display the section contents. $(‘#Projects’).html(result); }) .error(function (xhr, status) { alert(xhr.responseText); }); 我想要做的是将这些存储在一个名为renderpartial.js的javascript文件中,以便我可以将ajax调用添加到一个文件而不是将它们写入每个视图。 有谁知道这是否可能? 我试过试试 在我的页面顶部,但我得到的是错误function。

Codeigniter Ajax上传图片

我目前正在使用CodeIgniter为我的学校项目开发一些表单。 我的想法是我有一个带图像上传的表单。 我正在尝试使用Ajax动态地执行它,但它似乎根本不起作用。 我尝试使用php的非动态版本,它完美运行,我的图像在我的文件夹中,我没有问题。 我尝试了5或6个插件没有结果,这肯定是我的错,但我不知道我在哪里犯了错误。 if($result = $this->images_model->add_bdd()) { $data[‘uploaded’] = $result; $data[‘message_upload’] = ‘Image uploader avec succès.’; $this->template->set_title(‘Upload successful’); $this->template->view(‘add_places’,$data); } else { $this->template->set_title(‘Upload failed’); $this->template->view(‘add_places’); } function add_bdd() { $config = array( ‘allowed_types’ => ‘jpg|jpeg|tiff’, ‘upload_path’ => $this->gallery_path, ‘max_size’ => 2000, ‘remove_spaces’ => TRUE, ‘overwrite’ => FALSE ); $this->load->library(‘upload’,$config); if ($this->upload->do_upload()) { $data_img […]

等待Ajax完成其他function

我正在使用Ajax更新页面中的一些值。 然后,在完成之后,我需要使用该值来执行其他function。 我将一个函数放在另一个函数之后,但即使这样,第二个函数也没有等待Ajax完成。 $(document).ready(function(){ $(“.data”).blur(function(){ var id = $(this).attr(‘id’); var value = $(this).html(); var ad = id.split(‘;’); Update(valor, id); Function2(ad[1]); }); }); function Update(value, id){ if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) […]

通过ajax将当前页面html发送回服务器

在我的应用程序中,我通过jquery ajax将我的网页的html发送回服务器(因为我需要在服务器中存储此页面的副本).Code是这样的 $(document).ready(function () { var pcontent = document.body.innerHTML; var url = new URI().addQuery(“pcontent”, pcontent); $.ajax({ url: url, type: “GET”, success: function (data) { alert(data.html()); }, complete: function () { alert(1); }, error: function(jqXHR, error, errorThrown) { if (jqXHR.status) { alert(jqXHR.responseText); } else { alert(“Something went wrong”); } } }); return false; }); 但这会引发错误: Request […]