2

Doing an ajax get request works as expected using the following code

$K.ajax({
  type: "GET",
  contentType: "application/json",
  url: "http://someObscureURLThatIWontBeSharing/database/document",
  dataType: "jsonp",
  success: function(msg) {
    console.log(msg);
  },
  error: function(a,b,c) {
    console.log(a);
    console.log(b);
    console.log(c);
  }
});

But a PUT ajax call using the following code

$K.ajax({
  type: "PUT",
  contentType: "application/json",
  url: "http://someObscureURLThatIWontBeSharing/test/mrmer1",
  dataType: "jsonp",
  data: {"name":"mike"},
  success: function(msg) {
    console.log(msg);
  },
  error: function(a,b,c) {
    console.log("XMLHttpRequest: " + a);
    console.log("textStatus: " + b);
    console.log("errorThrown: " + c);
  }
});

results in the following console output

XMLHttpRequest: [object XMLHttpRequest]
textStatus: null
errorThrown: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://static.kobj.net/kobj-static-20100219162227.js Line: 371"]

I have been pulling my hair out trying to figure out why my ajax call wasn't working and finally output the previous to the console. I'm thinking there is something in the runtime that is blocking my request. Please help me out before I look like this

crazy

flag
BTW, love that you add an image to the end of your question. – Alex Mar 11 at 0:08

1 Answer

4

So, Most browsers don't support PUTs at this point. So just do a GET or a POST.

link|flag
That's REALLY not what I wanted to hear but OK. – Mike Grace Mar 10 at 18:04
Is it possible that you are encountering cross-domain restrictions? en.wikipedia.org/wiki/Same_origin_policy IDK, but maybe if you have some URL stuff like username@someplace.com, it is considered cross-domain? – Alex Mar 10 at 23:50
The runtime and system aren't relevant at this point. Once you do $K.ajax... it's between you and the other server. Kynetx is out of the picture. – Phil Mar 12 at 2:22
I thought it should work because I have been able to get an ajax PUT to work using jquery in other applications that I have built using the same browsers that I was testing for this app. So I'm guessing that POST & PUT are blocked cross domain. – Mike Grace Mar 15 at 22:44

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.