使用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
最满意答案
您将不得不为您的课程添加
__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 withfunctools.total_ordering
to add the other comparison operators as well.
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
您可以将优先级队列与一个集合组合在一起: 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 ...