last day (29 days later) » 

9:44 PM
0
A: Convert and upload canvas as image

Yotam OmerThe Access-Control-Allow-Origin header error means your service doesn't allow cross-domain requests. You can change this header like so (php): header("Access-Control-Allow-Origin: *"); Note that this will allow requests from any domain, for security reasons I would recommend replacing the * ...

 
I am using JavaScript and don't have control of the server. Why does it work on the form upload and not the AJAX post? Can I have my AJAX post act like the form upload?
 
Ajax is different from regular posting because your user is still on the original website and not transferred to the service website. You should also try changing the dataType of your ajax to: "jsonp"
Note the update: dataType : "jsonp"
 
I tried that earlier and again just now. It gives me a 500 error: 500 Problem(1) handling mapping-request for /endpoint : org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
 
can you make a jsfiddle? I will take a closer look.
 
I would like too, but the application vendor is very particular about their endpoints.
Thanks for you efforts on this
 
9:45 PM
I have another solution but it is a more complicated one so I moved to chat. let me know when you are here.
 
Right here
 
k
because you have no control on the service I would recommend this:
create an iframe on the page
 
Ok
 
lets say id="uploadFrame"
set you form target to "uploadFrame"
 
Its in place
 
9:47 PM
Then use the .load event of the iframe to know when it is done
 
I don't have a form, just a button to trigger the javascript function to convert the canvas
before uploading
 
You said it worked with regular form
 
Yes, I meant the webservice works with a form where users upload an image. I need to upload an canvas that is converted to an image so users don't have to manually upload
Basically, I would like the ajax call to upload properly since the form upload does with the same webservice
 
one sec
 
thank you
 
9:56 PM
Have you tried removing the dataType:jsonp and adding
crossDomain: true,
?
It seems like this can be done. We are missing something silly ;)
 
Yes, and agreed. I am getting a 200 OK status with or without the crossDomain: true, but then receiving an error of cross-domain as it sends data back with a response. I will take this up with the application vendor in the morning.
Thank you for all your assistance
 
No problem man, sorry it didnt work
 
hey, you pointed me in the right direction!
have a great evening
 
you 2
 

  last day (29 days later) »