我已经知道如何在jQuery中做到这一点(哦,男孩很容易),但我只是好奇如何在基本的javascript中完成这个,没有jQuery.毕竟,jQuery IS javascript,以及任何可以在一个中完成的东西,都可以在另一个中完成(而不像某些人想象的那样困难!)
请帮助满足我的好奇心!我想学习潜在的概念〜
一种常见的情况 - 用户执行多个ajax调用,并且只有在完成两个调用时才想执行一段代码.如何实现这一目标?
这是一个常见场景的简单示例.这是我到目前为止所尝试过的,(但没有奏效).我知道它不起作用的原因是因为在javascript中,一次只能处理一个ajax调用.那么,什么是这样做没有jQuery的正确方法是什么?
//gets result html code, for a settings div inside a log panel
//this page also inserts some info into my database
//it has to run first and finish first before second ajax call, runs
var xmlhttp;
if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","/scripts/post_login_panel_actions.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("settings_button_activate=1&display_image_url="+encodeURIComponent(settings_display_picture_url));
//gets result html code, for the login panel inside of which, there is a settings div
//this has to run after, so that it …Run Code Online (Sandbox Code Playgroud)