Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jsf.ajax.request在Firefox上不起作用_Ajax_Jsf_Firefox - Fatal编程技术网

jsf.ajax.request在Firefox上不起作用

jsf.ajax.request在Firefox上不起作用,ajax,jsf,firefox,Ajax,Jsf,Firefox,我有一个基于JSF2.1和Primefaces的应用程序。 我需要使用Jquery发出ajax请求并更新页面状态。 代码如下: <?xml version="1.0"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h

我有一个基于JSF2.1和Primefaces的应用程序。 我需要使用Jquery发出ajax请求并更新页面状态。 代码如下:

    <?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <f:view>
        <h:head>
        </h:head>
        <h:body>
            <h:outputText id="counterViewer" value="#{dataController.outputMessage}"
                          styleClass="counter-viewer" />
            <h:form id="dataForm" >
                <h:outputScript>
                    jQuery(document).ready(function() {
                        jQuery(document).on("count", function(event, count) {
                            alert( "Count: " + count );
                            document.getElementById("#{view.getClientId(facesContext)}:counterViewer").innerText = count;   
                            var hiddenCountValue = document.getElementById("#{view.getClientId(facesContext)}:dataForm:hiddenCountValue");
                            hiddenCountValue.value = count;
                            jsf.ajax.request(hiddenCountValue, 'change');
                        });
                     });
                </h:outputScript>
                <h:inputHidden id="hiddenCountValue" value="#{dataController.outputMessage}"/>
            </h:form>
        </h:body>
    </f:view>
</html>

jQuery(文档).ready(函数(){
jQuery(文档).on(“计数”,函数(事件,计数){
警报(“计数:+Count”);
document.getElementById(“#{view.getClientId(facesContext)}:counterViewer”).innerText=count;
var hiddenCountValue=document.getElementById(“#{view.getClientId(facesContext)}:dataForm:hiddenCountValue”);
hiddenCountValue.value=计数;
请求(hiddenCountValue,'change');
});
});
当我使用Chrome浏览器时,一切正常,但在Firefox22上,jsf.ajax.request(hiddenCountValue,'change');函数不起作用

还有其他功能可以在Firefox上运行我的代码吗? 为什么jsf.ajax.request(hiddenCountValue,'change');在firefox上工作

谢谢

Lucaf:查看>

当我使用Chrome everithyngs时,它工作得很好,但在firefox上

请求(hiddenCountValue,'change')

功能似乎不起作用

有没有其他函数可以让我的代码更兼容? 为什么

请求(hiddenCountValue,'change')

不能在firefox上工作

谢谢


Luca也不应该在Chrome上工作。这很可能是由于误解造成的。也许请求实际上已经发送了,但即使这样,它在服务器端也不会做任何有用的事情。您在
上没有任何
可以解码
jsf.ajax.request()

扔掉这种笨拙的破解/变通尝试。由于您已经在使用PrimeFaces,只需抓住它的
()

要了解
jsf.ajax.request
的实际工作原理,请阅读以下相关问题和答案:


    • 它也不应该在Chrome中工作。这很可能是由于误解造成的。也许请求实际上已经发送了,但即使这样,它在服务器端也不会做任何有用的事情。您在
      上没有任何
      可以解码
      jsf.ajax.request()

      扔掉这种笨拙的破解/变通尝试。由于您已经在使用PrimeFaces,只需抓住它的
      ()

      要了解
      jsf.ajax.request
      的实际工作原理,请阅读以下相关问题和答案:

      <h:form>
          <p:remoteCommand name="sendCount" process="@this" action="#{bean.processCount}" />
      </h:form>
      <h:outputScript target="body">
          $(document).on("count", function(event, count) {
              $(".counter-viewer").text(count);
              sendCount([{ name: "count", value: count }]);
           });
      </h:outputScript>
      
      public void processCount() {
          String count = FacesContext.getCurrentInstance().getRequestParameterMap().get("count");
          // ...
      }