开发者

ReturnFormat row when POSTing CFAJAX request

I'm struggling with the setQueryFormat() call to an AJAX-function in CF9. I have CFM-File that looks like so:

  <div id="div1" onclick="callfkt1('POST');" style="cursor:pointer;">POST</div>
  <div id="div2" onclick="callfkt1('GET');" style="cursor:pointer;">GET</div>
  <script type="text/javascript">
   function callfkt1(sHTTPMethod) {
    var oTester001=new CTester001();
    oTester001.setCallbackHandler(function(result) {
     alert(JSON.stringify(result));
    });
    oTester001.setErrorHandler(function(err, msg) {
     alert(err + ': ' + msg);
    });
    oTester001.setHTTPMethod(sHTTPMethod);
    oTester001.setQueryFormat('column');
    oTester001.fkt1();
   }
  &l开发者_运维知识库t;/script>

Tester001.cfc contains the following:

 <cfcomponent >
 <cffunction name="fkt1" returntype="query" access="remote">
  <cfquery name="local.queries.qry1" datasource="brdwr">
   SELECT url_id, url
   FROM urls
  </cfquery>
  <cfreturn local.queries.qry1>
 </cffunction>
</cfcomponent>

When I call the JavaScript function With parameter 'GET' the result is returned in query format 'column' which means it contains a ROWCOUNT member that stores the number of records returned from the query. Using request method 'POST' the recordset is returned in format 'row' without ROWCOUNT member. Have you experienced this? Do you limit to GETing CFAJAX request?

Best.


You might try changing your CFC so that you explicitly declare how you want the JSON returned by using the serilizeJson function:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_a-b_3.html

As the second argument of the function, you can set serializeQueryByColumns to True, so that it will serialize the data as a WDDX query format, which is what the setQueryFormat("column") is supposed to do.


While not an answer, do know that when the row format is used, you still get the same data. It's in a different format, but you still get all the data. You just have to work with it differently.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜