$ .post jquery中的内部服务器错误500?

时间:2016-04-21 08:56:26

标签: jquery ajax post

我的Jquery代码:

NSURLSession *session = [NSURLSession sharedSession];
NSError *error;
NSDictionary *mapData = @{
                          @"userIdentity": @{
                                  @"ticket": [SecretStorage sharedInstance].ticket,
                                  @"hotelId": [SecretStorage sharedInstance].hotelId,
                                  @"language": @"ru"
                                  }
                          };
NSData *postData = [NSJSONSerialization dataWithJSONObject:mapData options:0 error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"example.com"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:60.f];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];

NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
                                                NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
                                                NSLog(@"%@", json);
                                            }];
[dataTask resume];

我的Html代码:

$(document).ready(function() {
    $("#cat").change(function(e){
      $.post($("#cat").val(), function(html){
        $("#data").html(html);
      });
      return false;
    });
  });

但是当我更改selectbox来调用ajax时,我得到了内部服务器错误500,请帮我解决一下?

1 个答案:

答案 0 :(得分:1)

如果您尝试获取这些html文件的内容,则应使用$ .get()

$.get('out1.html')
  .done(function(data){
    $('#data').html(data);
  });
相关问题