Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8600041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:31:44+00:00 2026-06-12T01:31:44+00:00

I am trying to receive a JSON response in iPhone simulator using localhost web

  • 0

I am trying to receive a JSON response in iPhone simulator using localhost web service.

I turned on Web sharing and placed the php file named “readmain.php” in /Library/WebServer/Documents

When i write “http://localhost/readmain.php” in Chrome, I see the result displayed perfectly.

But when I try to receive the response in my app, an error is received.

I am using ASIHTTPRequest

Here’s the code:

NSURL *url = [NSString stringWithFormat:@"%@%@", HJServerAddress, @"readmain.php"];
DLog(@"request URL = %@", [url description])
self.httpRequest = [ASIHTTPRequest requestWithURL:url];
self.httpRequest.delegate = self;
[self.httpRequest startAsynchronous];
[self.activityIndicator startAnimating];

Where HJServerAddress is:
#define HJServerAddress @”http://localhost/”

Whenever the above piece of code executes, I get response from as failed in:

   - (void)requestFailed:(ASIHTTPRequest *)request
   {
       DLog(@"error: %@", [request.error description])
       ULog(@"Failed to load data")
   }

In Logs I get:

2012-09-24 17:44:06.153 _APPNAME_[1798:f803] -[HJHomeViewController fetchAddsJson] [Line 122] request URL = "http://localhost/readmain.php"
2012-09-24 17:44:46.457 _APPNAME_[1798:f803] -[HJHomeViewController requestFailed:] [Line 478] error: Error Domain=ASIHTTPRequestErrorDomain Code=10 "NSInvalidArgumentException" UserInfo=0x69656e0 {NSLocalizedFailureReason=-[__NSCFString absoluteURL]: unrecognized selector sent to instance 0xb650510, NSUnderlyingError=0x6960460 "The operation couldn’t be completed. (ASIHTTPRequestErrorDomain error 10.)", NSLocalizedDescription=NSInvalidArgumentException}

I had also tried to use the IP address of my MAC instead of using “localhost”.

I tried accessing the file from iOS simulator’s Safari and the response was received successfully.

I am unable to receive the response in my underdevelopment app. Am I doing something wrong in my code? Or is there something more to be done?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:31:45+00:00Added an answer on June 12, 2026 at 1:31 am

    You assign NSString object to NSURL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get a json response from google's geocoding service. I'm using
I am trying to consume PHP Web service with JSON in android I got
I am trying to receive a json object back from php after sending data
I;m trying to parse a json string which I receive from web server as
I'm trying to use fiddler to generate requests to receive a JSON response. I
I'm trying to receive a certain value in a json using AFNetworking. The value
I am trying to parse a Json response from my webservice. I receive this
I'm trying to send and receive using pipes: send.cpp struct { long a; long
when i try to parse the response returned from a web service i got
I am trying to append to an ordered list based on the JSON response

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.