You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Ronen (JIRA)" <ji...@apache.org> on 2011/02/04 23:32:31 UTC

[jira] Created: (COUCHDB-1059) jquery couch list function and html response

jquery couch list function and html response
--------------------------------------------

                 Key: COUCHDB-1059
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1059
             Project: CouchDB
          Issue Type: Bug
          Components: JavaScript View Server
    Affects Versions: 1.0.1
            Reporter: Ronen


Calling a list function from jquery couch that returns a non json response (html in my case) fails since the return type is hardcoded as json: 

      complete: function(req) {
        try {
          var resp = $.httpData(req,"json");
        } catch(e) {
   
      //....

This causes httpData to try and parse the returned data as json, by making this optional (adding returnType option to options):

          var resp = $.httpData(req, options.returnType? options.returnType:"json");

It is solved


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (COUCHDB-1059) jquery couch list function and html response

Posted by "Ronen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ronen updated COUCHDB-1059:
---------------------------

    Description: 
Calling a list function from jquery couch that returns a non json response (html in my case) fails since the return type is hardcoded as json: 

      complete: function(req) {
        try {
          var resp = $.httpData(req,"json");
        } catch(e) {
   
      //....

This causes httpData to try and parse the returned data as json, by making this optional (adding returnType option to options):

          var resp = $.httpData(req, options.returnType? options.returnType:"json");

It is solved, 

I can create a patch if required.


  was:
Calling a list function from jquery couch that returns a non json response (html in my case) fails since the return type is hardcoded as json: 

      complete: function(req) {
        try {
          var resp = $.httpData(req,"json");
        } catch(e) {
   
      //....

This causes httpData to try and parse the returned data as json, by making this optional (adding returnType option to options):

          var resp = $.httpData(req, options.returnType? options.returnType:"json");

It is solved



> jquery couch list function and html response
> --------------------------------------------
>
>                 Key: COUCHDB-1059
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1059
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.0.1
>            Reporter: Ronen
>
> Calling a list function from jquery couch that returns a non json response (html in my case) fails since the return type is hardcoded as json: 
>       complete: function(req) {
>         try {
>           var resp = $.httpData(req,"json");
>         } catch(e) {
>    
>       //....
> This causes httpData to try and parse the returned data as json, by making this optional (adding returnType option to options):
>           var resp = $.httpData(req, options.returnType? options.returnType:"json");
> It is solved, 
> I can create a patch if required.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COUCHDB-1059) jquery couch list function and html response

Posted by "Ronen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020695#comment-13020695 ] 

Ronen commented on COUCHDB-1059:
--------------------------------

Sorry I didn't see your response up till now, I guess that your covered

Thanks for the fix
Ronen




> jquery couch list function and html response
> --------------------------------------------
>
>                 Key: COUCHDB-1059
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1059
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.0.1
>            Reporter: Ronen
>
> Calling a list function from jquery couch that returns a non json response (html in my case) fails since the return type is hardcoded as json: 
>       complete: function(req) {
>         try {
>           var resp = $.httpData(req,"json");
>         } catch(e) {
>    
>       //....
> This causes httpData to try and parse the returned data as json, by making this optional (adding returnType option to options):
>           var resp = $.httpData(req, options.returnType? options.returnType:"json");
> It is solved, 
> I can create a patch if required.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (COUCHDB-1059) jquery couch list function and html response

Posted by "Jan Lehnardt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020679#comment-13020679 ] 

Jan Lehnardt commented on COUCHDB-1059:
---------------------------------------

This would be a patch:


diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index 9e31cef..c62ab9e 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -1024,8 +1024,9 @@
     options = $.extend({successStatus: 200}, options);
     ajaxOptions = $.extend({contentType: "application/json"}, ajaxOptions);
     errorMessage = errorMessage || "Unknown error";
+    var dataType = options.returnType ? options.returnType : "json";
     $.ajax($.extend($.extend({
-      type: "GET", dataType: "json", cache : !$.browser.msie,
+      type: "GET", dataType: dataType, cache : !$.browser.msie,
       beforeSend: function(xhr){
         if(ajaxOptions && ajaxOptions.headers){
           for (var header in ajaxOptions.headers){
@@ -1035,7 +1036,7 @@
       },
       complete: function(req) {
         try {
-          var resp = httpData(req, "json");
+          var resp = httpData(req, dataType);
         } catch(e) {
           if (options.error) {
             options.error(req.status, req, e);


> jquery couch list function and html response
> --------------------------------------------
>
>                 Key: COUCHDB-1059
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1059
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.0.1
>            Reporter: Ronen
>
> Calling a list function from jquery couch that returns a non json response (html in my case) fails since the return type is hardcoded as json: 
>       complete: function(req) {
>         try {
>           var resp = $.httpData(req,"json");
>         } catch(e) {
>    
>       //....
> This causes httpData to try and parse the returned data as json, by making this optional (adding returnType option to options):
>           var resp = $.httpData(req, options.returnType? options.returnType:"json");
> It is solved, 
> I can create a patch if required.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (COUCHDB-1059) jquery couch list function and html response

Posted by "Jan Lehnardt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020677#comment-13020677 ] 

Jan Lehnardt commented on COUCHDB-1059:
---------------------------------------

A patch would be great :)

> jquery couch list function and html response
> --------------------------------------------
>
>                 Key: COUCHDB-1059
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1059
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.0.1
>            Reporter: Ronen
>
> Calling a list function from jquery couch that returns a non json response (html in my case) fails since the return type is hardcoded as json: 
>       complete: function(req) {
>         try {
>           var resp = $.httpData(req,"json");
>         } catch(e) {
>    
>       //....
> This causes httpData to try and parse the returned data as json, by making this optional (adding returnType option to options):
>           var resp = $.httpData(req, options.returnType? options.returnType:"json");
> It is solved, 
> I can create a patch if required.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira