ajax 请求，简单实现，可以修改成使用 jQuery.ajax 如果已经依赖了的话。
11355
function ajax(url, cb, data) {
        var xhr = new(window.XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');

        xhr.onreadystatechange = function () {
            if (this.readyState == 4) {
                if (this.status !== 200) {
                    cb(this.responseText);
                }
                else {
                    cb(null, this.responseText);
                }
            }
        };
        xhr.open(data ? 'POST' : 'GET', url + '&t=' + (new Date()).getTime(), true);

        if (data) {
            xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        }
        xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
        xhr.send(data);
    }
522876
function () {
		var ajax = this.obj.$ajax;
		var self = this;
		var version = this.obj.getUserData(0, "version");
		var url = this.serverProcessor + ajax.urlSeparator(this.serverProcessor) + ["dhx_user=" + this._user, "dhx_version=" + version].join("&");
		url = url.replace("editing=true&", "");
		this.getUpdates(url, function (xml) {
			var vers = ajax.xpath("//userdata", xml);
			self.obj.setUserData(0, "version", self._v(vers[0]));

			var upds = ajax.xpath("//update", xml);
			if (upds.length) {
				self._silent_mode = true;

				for (var i = 0; i < upds.length; i++) {
					var status = upds[i].getAttribute('status');
					var id = upds[i].getAttribute('id');
					var parent = upds[i].getAttribute('parent');
					switch (status) {
						case 'inserted':
							self.callEvent("insertCallback", [upds[i], id, parent]);
							break;
						case 'updated':
							self.callEvent("updateCallback", [upds[i], id, parent]);
							break;
						case 'deleted':
							self.callEvent("deleteCallback", [upds[i], id, parent]);
							break;
					}
				}

				self._silent_mode = false;
			}

			self._update_busy = false;
			self = null;
		});
	}
194225
function onClicksetPresetData(){
$("#onClicksetPresetDataBtn").prop('disabled', true);
    setPresetData().then(()=>{
        alert("書き込み完了");
        $("#onClicksetPresetDataBtn").prop('disabled', false);
        $("#onplayPresetDataBtn").prop('disabled', false);

    }).catch((e)=>{
        alert(e);
        $("#onClicksetPresetDataBtn").prop('disabled', false);
    })
}
1345397
function genServiceMethod(method) {
        return function (req) {
            return ajax.send(method.url, method.httpMethod, req, method.resourceName);
        };
    }
605933
private function invokeRoute(): void
    {
        $moduleName = $this->routeInfo->moduleName;
        $controllerName = $this->routeInfo->controllerName;
        $actionName = $this->routeInfo->actionName;
        $controllerClass = $this->config->getValue('CONTROLLER_NAMESPACE') . '\\' . str_replace('.', '\\', $moduleName) . '\\' . $controllerName;
        if (! class_exists($controllerClass)) {
            $event = RouteErrorEvent::createCustom(404, $moduleName . '/' . $controllerName . '/' . $actionName . '对应的控制器类' . $controllerClass . '不存在');
            $event->httpErrorCode = 404;
            $this->dispatchEvent($event);
            return;
        }
        // 执行操作
        $this->invokeAction(new $controllerClass(), $actionName);
    }
106767
def ajax_only(view_func):
    """"""

    @wraps(view_func, assigned=available_attrs(view_func))
    def _wrapped_view(request, *args, **kwargs):
        if request.is_ajax():
            return view_func(request, *args, **kwargs)
        else:
            return http.HttpResponseBadRequest()
    return _wrapped_view
271658
function (file, that) {
				$.ajax({
					type: "post",
					url: that.options.imagesDeleteScript,
					data: {
						file: file
					}
				});
			}
88717
function htmlParse(data='<div></div>', options={}){
  var transData = {};//存放转化后的数据
  let res = {};  //返回的数据
  transData = html2json(data, 'root', options);
  // console.log('解析结果是', transData);
  res = transData;
  return res;
}
153054
public function handleAjaxCall()
    {
        $environment = $this->getEnvironment();
        $input       = $environment->getInputProvider();

        if (true === ($input->hasParameter('id'))) {
            // Redefine the parameter id if this isn´t model id conform.
            if (false === \strpos($input->getParameter('id'), '::')) {
                $modelId = new ModelId($input->getParameter('table'), $input->getParameter('id'));
                $input->setParameter('id', $modelId->getSerialized());
            }
            $modelId      = ModelId::fromSerialized($input->getParameter('id'));
            $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
            $model        = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));
        }

        $this->addAjaxPropertyForEditAll();

        $handler = new Ajax3X();
        $handler->executePostActions(new DcCompat($environment, ($model ?? null)));
    }
766178
function ()
    {
        var xhr = null;
        if (window.XMLHttpRequest) {
            xhr = new XMLHttpRequest();
            if (xhr.overrideMimeType) {
                xhr.overrideMimeType("text/xml; charset=utf-8");
            }
        } else if (window.ActiveXObject) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }

        // use Function.bind() to prepend ourselves as an argument
        xhr.onreadystatechange = this.func.bind(null, this);

        return xhr;
    }
791551
protected function ajaxResponseHandler()
    {
        echo json_encode([
            'success'      => $this->errorMessage ? 0 : 1,
            'errorMessage' => $this->errorMessage,
            'errorCode'    => $this->errorCode,
            'data'         => $this->errorMessage ? '' : $this->dataPacket,
        ]);

        die();
    }
1188242
function sendRequest(method, path, data, callback) {
  if (!CONFIG.isInitialized) {
    throw ERROR_MESSAGE.initializeRequired;
  }

  log("==================================================");
  log("The data below will be sent");
  log("==================================================");
  log(data);

  let dataString = querystring.stringify(data);

  let headers = {
    "Content-Type": "application/x-www-form-urlencoded"
  };

  // 使用 POST 時設定 Content-Length 標頭
  if (method === "POST") {
    headers["Content-Length"] = dataString.length;
  } else {
    path = `${path}?${dataString}`;
  }

  let options = {
    host: CONFIG.host,
    port: CONFIG.port,
    path: path,
    method: method,
    headers: headers
  };

  let request;
  if (!CONFIG.useSSL) {
    request = http.request(options);
  } else {
    request = https.request(options);
  }

  log("==================================================");
  log("HTTP/HTTPS request options");
  log("==================================================");
  log(options);

  if (method === "POST") {
    log("==================================================");
    log("Send request");
    log("==================================================");
    log(dataString);
    request.write(dataString);
  }

  request.end();

  let buffer = "";
  request.on("response", (response) => {
    response.setEncoding("utf8");

    response.on("data", (chunk) => {
      buffer += chunk;
    });

    response.on("end", () => {
      let responseData;

      log("==================================================");
      log("Response data");
      log("==================================================");
      log(buffer);

      if (callback) {
        let err = undefined;

        // 另外處理非 JSON 物件的返回值
        if (NON_JSON_RESPONSE_ENDPOINT.indexOf(path) > -1) {
          if (response.statusCode === 200) {
            if (path === ENDPOINT.aioChargeback) {
              let [status, message] = buffer.split("|");
              responseData = {
                status: status,
                message: message
              };
            } else {
              responseData = {};
              let responseArr = buffer.split("&");
              responseArr.forEach((param) => {
                let [key, value] = param.split("=");
                responseData[key] = value;
              });
            }
          } else {
            err = response.statusCode;
          }
        } else {
          try {
            responseData = JSON.parse(buffer);
          } catch (error) {
            log("==================================================");
            log("Could not convert API response to JSON, the error below is ignored and raw API response is returned to client");
            log("==================================================");
            log(error);
            err = error;
          }
        }

        callback(err, responseData);
      }
    });

    response.on("close", (err) => {
      log("==================================================");
      log("Problem with API request detailed stacktrace below");
      log("==================================================");
      log(err);
      sendErrorResponse(err, callback);
    });
  });

  request.on("error", (err) => {
    log("==================================================");
    log("Problem with API request detailed stacktrace below");
    log("==================================================");
    log(err);
    sendErrorResponse(err, callback);
  });
}
1050111
function ajax(url, options, callback, data, cache) {

  if (data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') {
    if (!cache) {
      data['_t'] = new Date();
    }
    // URL encoded form data must be in querystring format
    data = addQueryString('', data).slice(1);
  }

  if (options.queryStringParams) {
    url = addQueryString(url, options.queryStringParams);
  }

  try {
    var x;
    if (XMLHttpRequest) {
      x = new XMLHttpRequest();
    } else {
      x = new ActiveXObject('MSXML2.XMLHTTP.3.0');
    }
    x.open(data ? 'POST' : 'GET', url, 1);
    if (!options.crossDomain) {
      x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
    }
    x.withCredentials = !!options.withCredentials;
    if (data) {
      x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    }
    if (x.overrideMimeType) {
      x.overrideMimeType("application/json");
    }
    var h = options.customHeaders;
    if (h) {
      for (var i in h) {
        x.setRequestHeader(i, h[i]);
      }
    }
    x.onreadystatechange = function () {
      x.readyState > 3 && callback && callback(x.responseText, x);
    };
    x.send(data);
  } catch (e) {
    console && console.log(e);
  }
}
1255263
def _request(self, resource, action, data=None, headers=None):
        
        url, httpmethod = res_to_url(resource, action)
        return self.ajax(url, httpmethod, data, headers)
926494
function initListener ( controller ) {

            // 记录是否允许所有事件的监听
        var isBegin = false,
            // 记录是否需要更新曲线
            isUpdateable = false,
            paper = controller.paper,
            currentBezier = null,
            currentPointGroup = null;

        paper.on( "mousedown", function ( e ) {

            var point = null;

            e.preventDefault();

            if ( !controller.drawState ) {
                return;
            }

            // 切换监听状态
            if ( !isBegin ) {
                isBegin = true;
                currentBezier = createBezier( paper );
                currentPointGroup = createPointGroup( paper );

                listenPointGroup( currentPointGroup, controller );

                //设置当前controller处理的贝塞尔曲线
                controller.setBezier( currentBezier );
                controller.setPointGroup( currentPointGroup );
            }

            isUpdateable = false;

            // 获取当前鼠标点击在用户坐标系上的映射点
            point = e.getPosition();

            updateBezier( controller, point );

        } );

        // 绘制时 更新控制点
        paper.on( "mousemove", function ( e ) {

            var point = null,
                bezierPoint = null;

            e.preventDefault();

            if ( !controller.drawState ) {
                return;
            }

            if ( !isBegin || isUpdateable ) {
                return;
            }

            point = e.getPosition();

            currentBezier.getLastPoint().setForward( point.x, point.y );
            currentPointGroup.getLastPoint().setForward( point.x, point.y );

        } );

        // 编辑时拖动更新
        paper.on( "mousemove", function ( e ) {

            var mousePoint = null,
                currentPoint = null,
                pointIndex = -1;

            e.preventDefault();

            // 不可编辑
            if ( !controller.editable ) {
                return;
            }

            mousePoint = e.getPosition();
            pointIndex = controller._modifyStatus.pointIndex;
            currentPoint = currentPointGroup.getPointByIndex( pointIndex );

            switch ( controller._modifyStatus.pointType ) {

                case PointGroup.TYPE_FORWARD:
                    currentPoint.setForward( mousePoint.x, mousePoint.y );
                    currentBezier.getPoint( pointIndex ).setForward( mousePoint.x, mousePoint.y );
                    break;

                case PointGroup.TYPE_BACKWARD:
                    currentPoint.setBackward( mousePoint.x, mousePoint.y );
                    currentBezier.getPoint( pointIndex ).setBackward( mousePoint.x, mousePoint.y );
                    break;

                case PointGroup.TYPE_VERTEX:
                    currentPoint.moveTo( mousePoint.x, mousePoint.y );
                    currentBezier.getPoint( pointIndex ).moveTo( mousePoint.x, mousePoint.y );
                    break;

            }


        } );

        paper.on( "mouseup", function () {

            if ( controller.drawState ) {

                isUpdateable = isBegin;

            } else if ( controller.modifyState ) {

                controller.disableEdit();
                // 清空状态
                controller.clearModifySatus();

            }

        } );

    }
1215572
function ajax_return(data, status, xhr) {
    // If the update was successfull
    if (data.ok) {
	// Forget old value
	this.removeData('old-value');
	// Add a green V to the right
	this.parent().next()
	    .off('click')
	    .html('V')
	    .css('color', 'LimeGreen')
	    .attr('title', 'Update OK');

	// If we modified the id
	if (this.attr('id') == 'id') {
	    var url = '/user?id=' + encodeURIComponent(this.val());
	    // update the link in the header...
	    $('#user-link')
		.text(this.val())
		.attr('href', url);
	    // ...and the url in the adress bar
	    history.pushState(null, null, url);
	}
    } else {
	// Add a red X to the right
	var elem = this;
	elem.parent().next()
	    .html('X')
	    .css('color', 'red')
	    .attr('title', data.message)
	    .one('click', function() { 	  // if the X is clicked, restore original data
		elem.val(elem.data('old-value'));
		$(this)
		    .empty()
		    .removeAttr('title');
	    });
    }
    // reactivate the control
    this.prop('disabled', false);
}
1196217
function onReady() {
  const self = this;

  /***
   * 判断页面是否已经ready
   */
  if (this.hasInited) return;
  this.hasInited = true;

  /***
   * window.document.body的jQuery
   */
  this.bodyDOM = window.document.body;

  /***
   * 存放完全单例对象的容器
   */
  this.singleInstances = null;

  /***
   * 创建page切换时的遮罩层
   */
  this.maskDOM = $(
    "<div class='ct-page-mask'>" +
    " <div opt='animation' class='la-ball-circus la-dark' style='color:#3e98f0;'>" +
    "   <div></div>" +
    "   <div></div>" +
    "   <div></div>" +
    "   <div></div>" +
    "   <div></div>" +
    " </div>" +
    "</div>")[0];
  this.bodyDOM.appendChild(this.maskDOM);


  /***
   * initialLocalTemplate都完成后初始化第一页 and LinkCapture
   */
  Promise.all(
    [
      initialLocalTemplatePromise.call(this),
      LinkCapturePromise.call(this)
    ]
  ).then(() => {
    console.timeEnd("总用时");
    fireEvent(window.document, "pageBeforeChange", [CtMobileFactory.getUrlParam(window.location.hash)]);
    /***
     * 初始化第一页
     * TODO:初始化第一页
     */
    createPage.call(this, this.getFirstId()).then((page) => {
      page.start(0, () => {
          /***
           * if(有hash值) 加载的不是首页而是某一个指定的页面 {
           *   调用startPage即可
           *   startPage需要三部分值
           *   1.html的路径
           *   2.pageId
           *   3.parameter
           * }
           */
          const hash = window.location.hash;
          if (!hash) return false;

          const pageId = self.getPageIdByHash();
          if (!pageId) return false;

          const pageRouterConfig = self.config.router[pageId];
          if ((pageRouterConfig && !pageRouterConfig.url)) return;
          const url = (pageRouterConfig && pageRouterConfig.url) ? pageRouterConfig.url : `#${pageId}`;
          const parameter = self.getParameterByHash();
          const searchObj = CtMobileFactory.getUrlParam(`${url}${parameter}`);

          self.startPage(`${url}${parameter}${parameter ? (searchObj.pageId ? '' : `&pageId=${pageId}`) : `?pageId=${pageId}`}`, {
            reload: self.config.linkCaptureReload
          });
        }
      );
    });
  });

}