首页 \ 问答 \ 使用ajaxFileUpload时出现[object%20Object]错误(get [object%20Object] error when using ajaxFileUpload)

使用ajaxFileUpload时出现[object%20Object]错误(get [object%20Object] error when using ajaxFileUpload)

我有一个javaScript脚本如下:

$.ajaxFileUpload({
        url: url,
        secureuri: false, 
        fileElementId: ['upload-file'], 
        dataType: "JSON", 
        data:{ "sample_path":$(".demo-view-container-left .view img").attr("src")},
        success: function (data)  
        {
            data=JSON.parse(data);
            json = JSON.stringify(data.prediction, undefined, 4)
            var c=document.getElementById("myCanvas");
            var cxt=c.getContext("2d");
            var cxt_text=c.getContext("2d");
            for(var i=0; i<data.prediction.length; ++i){
              score_location=data.prediction[i][i.toString()]
              location=score_location['location']
              cxt.moveTo(location['left'], location['top']);
              cxt.lineTo(location['left']+location['width'], location['top']);
              cxt.lineTo(location['left']+location['width'], location['top']+location['height']);
              cxt.lineTo(location['left'], location['top']+location['height']);
              cxt.lineTo(location['left'], location['top']);
              cxt.stroke();
              cxt_text.font="12px";
              cxt_text.fillText(score_location['score'].toString(), location['left'], location['top']);
            }
            $(".demo-view-container-right p").html("预测JSON:<br>"+json)
        },
        error: function (data)
        {  
        }

它可以进入success部分并执行所有行,但最后它转到一个新的URL,它是附加[object%20Object]当前URL,导致404错误。 如何解决这个问题呢? 谢谢。


I have a javaScript script as follows:

$.ajaxFileUpload({
        url: url,
        secureuri: false, 
        fileElementId: ['upload-file'], 
        dataType: "JSON", 
        data:{ "sample_path":$(".demo-view-container-left .view img").attr("src")},
        success: function (data)  
        {
            data=JSON.parse(data);
            json = JSON.stringify(data.prediction, undefined, 4)
            var c=document.getElementById("myCanvas");
            var cxt=c.getContext("2d");
            var cxt_text=c.getContext("2d");
            for(var i=0; i<data.prediction.length; ++i){
              score_location=data.prediction[i][i.toString()]
              location=score_location['location']
              cxt.moveTo(location['left'], location['top']);
              cxt.lineTo(location['left']+location['width'], location['top']);
              cxt.lineTo(location['left']+location['width'], location['top']+location['height']);
              cxt.lineTo(location['left'], location['top']+location['height']);
              cxt.lineTo(location['left'], location['top']);
              cxt.stroke();
              cxt_text.font="12px";
              cxt_text.fillText(score_location['score'].toString(), location['left'], location['top']);
            }
            $(".demo-view-container-right p").html("预测JSON:<br>"+json)
        },
        error: function (data)
        {  
        }

It can go into success part and execute all lines, but finally it go to a new URL which is current URL appended [object%20Object]resulting in a 404 error. How to solve this problem? thank you.


原文:https://stackoverflow.com/questions/46407434
更新时间:2022-09-24 17:09

最满意答案

您将不得不为您的课程添加__lt__方法:

def __lt__(self, other):
    return self.age < other.age

如果你想要安全,也可以添加一个__eq__方法,并用functools.total_ordering来修饰你的类来添加其他的比较运算符。


You will have to add a __lt__ method to your class:

def __lt__(self, other):
    return self.age < other.age

If you want to be safe, add a __eq__ method as well and decorate your class with functools.total_ordering to add the other comparison operators as well.

相关问答

更多
  • 您可以将优先级队列与一个集合组合在一起: import heapq class PrioritySet(object): def __init__(self): self.heap = [] self.set = set() def add(self, d, pri): if not d in self.set: heapq.heappush(self.heap, (pri, d)) self ...
  • 在您的示例数据[5, 53, 531, 5131] sift_up [5, 53, 531, 5131] ,您在sift_up表达的计算将如下所示: # Append 1 to the end --> [5, 53, 531, 5131, 1] # The index for '1' is 4, so 'item' is 4. # (4-1) // 2 = 1 (and 1 >= 0), so 'parent' is 1. # The value at 'parent' is 53. 53 > 1 is ...
  • 我的主要问题是我真的不知道如何正确地实现multiprocessing.queue,因为它们将是独立的队列,所以不能真正实例化每个进程的对象,如何确保所有进程与共享队列相关(或在这种情况下,队列) 这是一个读写器共享单个队列的简单示例...作者向读者发送一堆整数; 当作者用完数字时,会发送“DONE”,让读者知道从读取循环中脱离出来。 from multiprocessing import Process, Queue import time def reader(queue): ## Read ...
  • Queue是先进先出 ,这意味着插入的第一个元素是第一个检索到的元素,按照插入的顺序。 既然你没有办法控制它,我建议你在队列中插入元组,包含值和一些可用于排序/关联到原始计算的识别对象。 result = (1 / A[index, index]) * (b[index] - sum) q.put((index, result)) 这个例子将索引放入Queue和结果中,这样当你.get()稍后你也可以得到索引并用它来知道这是哪个计算: i, x_i = q.get(True) x_update[i] = ...
  • 你的问题似乎在你的队列中。 def enqueue(self, item, priority): self.PQ.insert(item) 根本不使用优先级参数。 相反,您的堆正在使用字符串比较。 这是任何出列前的堆状态: [None, 'Yamagata', 'Tetsuo', 'Shikishima', 'Takashi', 'Masaru', 'Akira', 'Kiyoko', 'Kei', 'Kaneda'] Your problem seems to be in your e ...
  • 您将不得不为您的课程添加__lt__方法: def __lt__(self, other): return self.age < other.age 如果你想要安全,也可以添加一个__eq__方法,并用functools.total_ordering来修饰你的类来添加其他的比较运算符。 You will have to add a __lt__ method to your class: def __lt__(self, other): return self.age < other.ag ...
  • 我会查看仪器包。 检测您感兴趣的类,以便ctor注册创建的实例。 如果您不想使用java.lang.instrument,或者如果通过您可以控制的东西(IoC容器或工厂)创建对象,那么您可以通过AspectJ执行此操作,那么您可以做一些不太神奇的好块。 I'd look into the the instrument package. Instrument the classes you are interested in so the ctor registers the created instance ...
  • 我建议用collections.deque替换Queue.Queue使用。 Queue类旨在用于线程之间的同步通信,因此在用作常规数据结构时会产生一些不必要的开销。 collections.deque是一个更快的选择。 (名称“deque”的发音为“deck”,意思是“双端队列”。) deque类的确有与Queue类型不同的API,但它们之间的转换应该很容易。 使用deque.append代替Queue.put和deque.popleft代替q.get() (或者appendleft和pop ,如果你想转向 ...
  • 我觉得它也很混乱,但从一个不同的角度来看。 假设您想按升序对序列进行排序。 有几种方法可以做到: 把你的数据放在一个std::vector或std::deque并使用std::less运行std::sort() 。 将您的数据放在std::list并使用std::less运行std::list::sort() 。 将数据插入到使用std::less配置的std::set中,最后自动排序。 把你的数据放在std::vector或std::deque ,然后使用std::less运行std::make_heap ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)