Tag: ajax

ajax jquery不会对ie工作

大家好。 我使用的js / ajax脚本不适用于Internet Explorer。 Firefox还可以。 顺便说一下头标记,即时使用: $(document).ready(function () { //Check if url hash value exists (for bookmark) $.history.init(pageload); //highlight the selected link $(‘a[href=’ + document.location.hash + ‘]’).addClass(‘selected’); //Seearch for link with REL set to ajax $(‘a[rel=ajax]’).click(function () { //grab the full url var hash = this.href; //remove the # value hash = hash.replace(/^.*#/, ”); […]

ajax回调不支持.done?

我已将.done添加到我的ajax回调中,现在正在获取 错误:对象不支持此属性或方法 在myPage.aspx中 : function myFunction(albumNb) { alert(“START myFunction”); var aNb = albumNb.toString(); $.ajax({ url: ‘myPage.aspx/TestFunction’, type: “POST”, contentType: “application/json; charset=utf-8”, data: “{‘name’:'” + aNb + “‘}”, dataType: “json” }).done(function (result) { alert(“done !”); }); } 我的代码出了什么问题? 我尝试使用.done等待代码隐藏中的TestFunction()来完成并返回result 。 我需要处理这个result 。 谢谢

使用jQuery ajax的javascript数组到php

可能重复: 通过JQuery $ .ajax将JavaScript数组传递给PHP 我试图将从n个动态生成的输入收集的一些变量传递给带有ajax的php。 这是动态生成的输入(可能有1或100)。 现在,如果我在没有ajax的情况下提交它们,它只需要在php中为我提供一个数组 $services = $_POST[‘service’]; 但是,如果我想在没有刷新页面的情况下使用ajax做什么呢? var action = $(“form_act”).attr(‘action’); var form_data = { service: $(“#service”).val(), ajax_request: 1 }; $.ajax({ type: “POST”, url: action, data: form_data, dataType: “json”, success: function (response) { if (response.error == ‘none’) $(“#form_content”).slideToggle(‘slow’, function () { $(‘#form_content’).load(‘includes/db_setup_form.php’); $(“#form_content”).delay(500).slideToggle(‘slow’); }); else { $(“#ajax_response”).html(“” + response.msg + “”); […]

jQuery加载对话框AJAX’完成’捕获回显结果

我有一个页面,我使用load来加载对话框。 从那个对话框中,我有jQuery在那里发布ajax请求到PHP脚本。 一切正常。 从PHP我回显结果并尝试从这个加载的对话框中捕获done回调 – 但它不起作用。 它更新了数据库,但我无法捕获回声。 这适用于我网站的其他地方,但我不能在这里工作。 我认为这可能与这个来自“加载”对话框的事实有关? 任何帮助,将不胜感激。 原始页面上的代码启动加载… $(‘#edit_cats’).click(function() { $(‘#overlay’).show(); $(“#loader4″).show().center(); $(‘#dialogLoad’).show().load(‘../../dialog/categories.php’, {‘site_user’:”,’id’:”}); }); 加载的对话框中的AJAX代码 $(‘.cat_input’).bind(‘blur keyup’, function(e) { if(e.type === ‘keyup’ && e.keyCode !== 10 && e.keyCode !== 13) return; $(this).hide(); var cat_title = $(this).val(); var cat_id = $(‘.cat_selected’).attr(‘id’); $.ajax({ type: “POST”, url: “../../system/process-cat-update.php”, dataType: “json”, data: { ‘title’:cat_title, ‘cat_id’:cat_id} […]

AJAX标题(Firefox与Chrome)

我遇到了一个涉及AJAX调用的有趣情况,并想知道是否有人可以提供某种解释。 1. $.ajax({ 2. type: “POST”, 3. headers: { 4. “Content-Type”: “application/json” 5. “authToken”: //auth token 6. }, 7. url: “/api”, 8. data: JSON.stringify(dataFormValues) 9. }) 10. .done(function(data) { 11. //do the next thing 12. }) 13. .error(function(data) { 14. //show error message 15. }); 这很有效,直到我们在Firefox中测试。 显然,如果没有将第4行修改为以下内容,这将无法在Firefox中运行: …. 4. “Content-Type”: “application/json;charset=utf-8” …. 然后,一旦转向Internet Explorer(IE 11)中的测试,我注意到它甚至不关心标题是什么; […]

如何使用AJAX加载PHP脚本?

我想知道加载PHP页面并使用AJAX插入页面的一部分的最佳技术? 例如,请考虑以下HTML代码: Website Logo Home Help Contact //CONTENT LOADS HERE// 在内容Div部分中使用AJAX加载页面(例如https://stackoverflow.com/questions/5599385/how-to-load-a-php-script-using-ajax/help.php或https://stackoverflow.com/questions/5599385/how-to-load-a-php-script-using-ajax/contact.php)的最佳方法是什么? 如果有帮助的话,我正在为我的网站使用JQuery库。

Jquery Ajax将数据发布到本地文件

我试图将本地文本文件的内容读入文本区域,然后修改textarea,然后将修改后的文本区域值保存到同一本地文件中。 我不能使用服务器端代码,所以尝试使用Jquery Ajax post方法。 我的HTML看起来像这样 – Edit Properties var testpath; var buildpath; var dataOnFile; var buildnum; function loadFile() { var URL = “somepath”; if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); } else { xhttp = new ActiveXObject(“Microsoft.XMLHTTP”); } xhttp.open(“GET”, URL, false); xhttp.send(“”); return xhttp.response; } function edit(){ $(document).ready(function() { //console.log(loadFile()); $(“#area”).val(loadFile());//load the contents correctly $(“#save”).click(function() […]

从动态创建的select选项调用时,JQuery Mobile changePage()片状?

我有一个带有简单选择菜单的Jquery Mobile页面。 Heroes: Choose One… Option 1 Option 2 在事件pageinit ,我使用jQuery来从.remove()选择菜单中的所有内容,然后我动态添加许多选项。 当然,我不会忘记刷新选择菜单。 function populateHeroNames(){ //populate hero select item $(‘#heroSelectMenu’).empty(); $(‘#heroSelectMenu’).append(‘Please Choose…’); for(var i=0;i<heroNameLength;i++){ if(heroName[i]){ var currentHeroName = heroName[i]; }else{continue;} $('#heroSelectMenu').append('’+currentHeroName+”); } //refresh hero select item var heroSelectMenu = $(“#heroSelectMenu”); heroSelectMenu.selectmenu(“refresh”); console.log(‘heroes added!’); } 我的问题是我无法成功导航到以编程方式创建的选项的不同页面。 我可以从硬编码选项中做到这一点。 当我点击硬编码选项时,我可以正常使用$.mobile.changePage() 。 但是从编程创建的选项中,我导航到的页面将消失,然后返回到初始页面。 在测试中,当我点击后退按钮时,我实际上是去了我的目的地。 所以很明显JqueryM已经导航到了目的地,但后来出于某种原因又回来了。 我怀疑原因是Jquery Mobile的奇怪DOM加载。 有什么我需要刷新……或者可能防止刷新? 只需导航到页面……并留在那里!

创建Django依赖下拉列表不会自动填充第二个下拉列表

我正在尝试使用此代码创建两个下拉列表,其中第二个下拉列表取决于第一个下拉列表。 但是我无法首先填充第二个下拉列表。 这是我关注的post: http://www.devinterface.com/blog/2011/02/how-to-implement-two-dropdowns-dependent-on-each-other-using-django-and-jquery/ 这是我的views.py函数: def createNewLocality(request,newLocality): return render(request, ‘locality/createNewLocality.html’, {‘term’: newLocality,’tag’: tagList()}) def all_json_models(request, tag): current_tag = Tag.objects.get(pk=tag) parents = Tag.objects.all().filter(parent__lt=current_tag) json_parents = serializers.serialize(“json”, parents) return HttpResponse(json_parents, content_type=”application/javascript”) 我的createNewLocality.html文件: Create New Locality $(document).ready( function() { $(“select#tag”).change(function() { if ($(this).val() == ‘Z’) { $(“select#parent”).html(“Select a parent”); $(“select#parent”).attr(‘disabled’, true); } else { var url = “tag/” […]

ASP.NET通过Ajax或jQuery浮动Div菜单

问题:我有一个主页,指示css,html,head,body内容,所以我不能使用浮动div技术,需要通过ajax / asp唯一的路径。 我能够在网上找到关于这个主题的所有内容都是人们在实现这个问题时遇到了问题但没有实际的工作示例代码。 我尝试在jtricks.com上使用基于jQuery的浮动div菜单 ,但是指令是针对html文件而不是asp.net文件,并导致页面加载出错。 This is a floating javascript menu. floatingMenu.add(‘floatdiv’, { // Represents distance from left or right browser window // border depending upon property used. Only one should be // specified. // targetLeft: 0, targetRight: 10, // Represents distance from top or bottom browser window // border depending upon property used. […]