-1

Asp.net page with jquery 1.7.1 When I post it from an Android phone via an emulator in Eclipse the post without the http://www.somedomain.com/ works perfectly. If i include the http url it does not work. The insert into the database is fine with wfo_s.aspx but not with http://www.somedomain.com/wfo_s.aspx

If anyone can shed some light on why this is happening, I would really appreciate it. Thanks!

//this does not work?
//$.post("http://www.somedomain.com/wfo_s.aspx", { the_User: theheatmap, conn: db_connection }, function (data) { });
//$.post("http://www.somedomain.com/wfo_s.aspx?the_User=" + theheatmap + "&conn=" + db_connection);
//this does work, why does the post to the url not work, page works fine 
//$.post("wfo_s.aspx", { the_User: theheatmap, conn: db_connection }, function (data) { });
//$.post("wfo_s.aspx?the_User=" + theheatmap + "&conn=" + db_connection);
Naftali
  • 144,921
  • 39
  • 244
  • 303
Rob
  • 1,226
  • 3
  • 23
  • 41
  • 2
    Most probably `http://www.somedomain.com` is not the same server (domain, sub domain and protocol) as the one that served the current page. – devnull69 Jul 17 '12 at 19:47
  • Maybe it won't work because it is all commented out? – Naftali Jul 17 '12 at 19:52
  • Tested locally or on the remote server, the http url from android emulator does not post to database. But when i just use wfo_s.aspx... it works perfectly? If I run the same code on my regular laptop both methods work. – Rob Jul 17 '12 at 19:55
  • possible duplicate of [Cross-Domain Requests with jQuery](http://stackoverflow.com/questions/7638773/cross-domain-requests-with-jquery) ok well nevermind this is not the case I suppose. – rlemon Jul 17 '12 at 19:55
  • 1
    are you sure you are not trying to connect (locally) to http://localhost.com??? – rlemon Jul 17 '12 at 19:56
  • @rlemon who connects to localhost.com? :-P – Naftali Jul 17 '12 at 19:57
  • yes not localhost. I can see the remote database being updated with wfo_s.aspx post either from my local visual studio or running it from the server. – Rob Jul 17 '12 at 19:58
  • locally or remote ... this does not matter! The only thing that counts is that the server that served the current page must(!) be `http://www.somedomain.com` – devnull69 Jul 17 '12 at 19:58
  • @Neal who tries to make cross domain XHR requests? :P – rlemon Jul 17 '12 at 19:59
  • @Rob does your dev tools (chrome) network tab show any 4xx or 5xx errors? This will tell you if the issues are with finding the page. – rlemon Jul 17 '12 at 20:00

2 Answers2

1

You cannot do ajax requests cross site.

There are some hacks (eg: jsonp) but not with regular requests.

Naftali
  • 144,921
  • 39
  • 244
  • 303
0

Doh! I was testing Android 1.5 and then loaded Android 2.1 and the post now works.

Rob
  • 1,226
  • 3
  • 23
  • 41