how to implement xmlhttprequest in posting data
how to implement xmlhttprequest in posting data
- Subject: how to implement xmlhttprequest in posting data
- From: "Namrata Dwivedi" <email@hidden>
- Date: Mon, 11 Sep 2006 18:26:16 +0530
Hi!
i'm a newbie.I was trying to post an http request but i'm not able to do so.
could anyone help me with the code.
i'm putting the code here but when i'm using this the server is geting
a null value.
if something can be done in tis code itself or if something else can
be suggested.
#import "ConverterController.h"
@implementation ConverterController
- (IBAction)convert:(id)sender
{
int num1,num2;
num2 =[dollarField floatValue];
num1 = [rateField floatValue];
NSNumber *number1 = [NSNumber numberWithInt:num1];
NSNumber *number2 = [NSNumber numberWithInt:num2];
NSString* tempurlstring;
NSString* URLString;
NSString* resultString;
NSMutableData *receivedData=nil;
unsigned char *firstBuffer,*buffer;
NSURLConnection* theConnection;
int stringlen;
tempurlstring = [NSString
stringWithCString:"http://145.36.149.31:8080/CBuild/servlet/HelloAddition"];
NSString *inputs;
NSString *tempinputs;
tempinputs = [NSString stringWithCString:"input_1="];
inputs = [tempinputs stringByAppendingFormat:@"%@ &input_2=%@",
number1,number2];
NSMutableURLRequest *postURLRequest=[NSMutableURLRequest
requestWithURL:[NSURL URLWithString:tempurlstring]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[postURLRequest setHTTPMethod:@"POST"];
[postURLRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
NSData *data = [NSData dataWithBytes:inputs length:[inputs length]];
[postURLRequest setHTTPBody:data];
theConnection=[[NSURLConnection alloc] initWithRequest:postURLRequest
delegate:self];
if (theConnection)
{
receivedData=[[NSMutableData data]retain];
}
firstBuffer = [receivedData mutableBytes];
resultString = [NSString stringWithCString:firstBuffer];
[amountField setStringValue:resultString];
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden