本文介绍了将图像数组传递给$ .ajax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想通过ajax帖子将数组图像传递给 WebMethod 。我写了下面的代码,但是我收到了错误。 请帮帮我。Hi,I want to pass an array images though ajax post to a WebMethod. I have written the following code, but I am getting error in that.Please help me in this.var imageArray= GetImage();$.ajax({ type: "POST", url: "Default.aspx/Save", data: "{htmlDiv:'" + htmlDiv + "',postData:'" + postData + "',ImageArray:'" + imageArray+ "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { alert('success'); }, error: function (ex) { return true; } });function GetImage() { var canvas = document.getElementById("canvasTest"); var context = canvas .getContext("2d"); //return { index: 0, image: canvas .toDataURL() }; var imageArray= []; imageArray[imageArray.length] = canvas .toDataURL() return canvas ;} 谢谢,Thanks,推荐答案 谢谢,Thanks,var imageArray = new Array(); 3. imageArray [imageArray.length] - 什么是 imageArray.length ??? 4.3. imageArray[imageArray.length] - What is the imageArray.length ???4.var context = canvas .getContext("2d");imageArray[imageArray.length] = canvas .toDataURL() 额外的空格是在选择器之后。 它应该是Extra spaces are there after the selectors.it should bevar context = canvas.getContext("2d");imageArray[imageArray.length] = canvas.toDataURL() 5. context 已声明,但未使用。 6. htmlDiv , postData 未定义。5. context is declared, but not used.6. htmlDiv, postData not defined. 这篇关于将图像数组传递给$ .ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-11 20:31