java - Access-Control-Allow-Origin for ajax call and HttpURLConnection -


I was trying to access a web-url (which is not accessible to me) that would return a JSON formatted string. / P>

I tried with AJAX calls and it shows that ' No access-control-permission-generating' header exists at the requested resource .

Then I found an alternative solution to get JSON data using HttpURLConnection

Can anyone tell me that both work , Because the requests have been made from the local host itself.

Below is my code in both ways:

AJAX:

  var request = $ .jg ({url} : "Url", type: "go", crossdaman: true, data: "content =" + component: list, data type: 'jason'});   

HttpURL connection:

  URL obj = new URL (URL); HttpURLConnection con = (HttpURLConnection) obj.openConnection (); Con.setRequestMethod ("GET"); Int responsivecode = con.getResponseCode ();    

simply type data: ingredient list, Should have the format automatically

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -