jquery - Make Ajax-call and take care of the response -


I use a free API for collecting users information from Ip-adress.

This method:

  public JsonResult GetIp () {string url = "http://ip-api.com/json"; Dynamic googleResults = new URI (url) .GetDynamicJsonObject (); Jason Returns (GoogleResults, JsonRequestBehavior.AllowGet); }   

When this page is provided to the method, then I am thinking this way:

  $ (document) .ready (function ("Type" "Post", url: '@ Url.Action ("GetIp", "Home"), Content Type: "Application / Jason; Charset = UTF-8", Datatype: "Jason ", // here I need the code which receives JSON from the controller ...});};   

Besides, is it the best way to go about this kind of work? I was reading that Jason can also be passed as a simple string? Any suggestions on best practice appreciated. Thank you.

You will not find the client in this way, you will get a server IP because it calls the machine.

Do you want the call to be directly in JavaScript, so the request is from the IP client.

If you see the feedback header of that API, access-control-permission-origin = *, so that you can use that URL directly.

And as Amin has mentioned, add a method of success to handle the reaction like this:

  $ (document) .ready (function () {$ .ajax ({type: "GET", url: 'http://ip-api.com/json', data type): "Jason", success: work (resp) {//resp.query}})} };   



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 -