0

I've been trying out lots of tutorials and SO question to find a way to make the below code work in obj-c. Its a json response from the server, but nothing i've tried works. How should I make the below code in obj-c?

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script>
$.ajax({

    url: "http://myjsonurl.com",
    data: { employerID: "1", startDate: "2013-09-13", endDate: "2013-09-15" },
    success: function(data) { console.log(data); }
});
</script>
</head>
</html>
2
  • Is the JSON server in your domain? If not, you'll need to use JSONP and the server will need to support it. Commented Sep 19, 2013 at 12:37
  • its in my domain, yeah. @Andy My problem isn't not getting an answer, its actually sending the request, simple as that Commented Sep 19, 2013 at 12:41

2 Answers 2

1

Change this response page to be purely JSON like so,

{ "employerID": 1, "startDate": "2013-09-13", "endDate": "2013-09-15" }

Make sure to put quotes around those keys unless they are variables.

You can use a third-party tool (linked to one below) to call this url and get the response as data, then convert the data to a NSJSONSerialization object in the completion block.

https://github.com/andrewapperley/AFFNetworking

Sign up to request clarification or add additional context in comments.

Comments

0

This is not only json response HTML script also came , Inform to your web-service person clear the HTML script give as array , dictionary format result

3 Comments

what? I can't understand what you're trying to say
this is not a json response.This is just html page.
html page in json format or whatever then, server guy says it is

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.