Welcome! Log In Create A New Profile

Advanced

PHP Autocomplete AJAX problem with NginX

Posted by westdude 
PHP Autocomplete AJAX problem with NginX
May 30, 2012 11:45PM
All.

I'm new with using the NginX server and currently we're having a very strange problem with the PHP and Ajax parameter running on NginX. Here is what I'm trying to do. I have an autocomplete php apps that used AJAX.
So the URL setting is as follow:

url="/user/getajax"

Say, I'm trying to search for city of San Francisco. When I enter the first letter S, the ajax supposed to pass the S character as the parameter to kick off the Ajax and start searching for all the city that starts with S and show it to the autocomplete field. However, when I entered the S character, the S character parameter wasn't passed to the AJAX. NginX ended up calling the whole URL parameter which is the /user/getajax and pass it as the parameter rather than the letter S as the parameter. I hope I'm making some sense with my problem description and perhaps anyone of you the NginX guru can share with me the setting I need to have in my nginx.conf in order for the AJAX to work properly.

Here is the setting for my NginX.conf and virtual.conf.

NginX.conf

user nobody;
worker_processes 5;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 8192;

events {
worker_connections 4096;
}

http {
include /etc/nginx/mime.types;
# include /etc/nginx/proxy.conf;
# include /etc/nginx/fastcgi.conf;
include /etc/nginx/fastcgi_params;
include /etc/nginx/conf.d/virtual.conf;
# index index.html index.htm index.php;
index index.php;

default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts

}


Virtual.conf
server {
listen 80;
server_name 192.168.1.219;

access_log /var/log/nginx/myapps.net.log;
root /var/www/html/myapps;


location / {
if (!-f $request_filename) {
rewrite ^(.*)$ /index.php?q=$1 last;
break;
}
}
# serve static files
location ~ ^/(images|js|css|flash|media|static)/ {

root /var/www/html/myapps;
expires 30d;
}


error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}


location ~ \.php$ {
root /var/www/html/myapps;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}


location ~ /\.ht {
deny all;
}
}


I'm really stumped and I hate to not being able to use NginX for our apps just because of the Ajax problem with Autocomplete. We have seen a tremendous improvement of speed utilizing NginX compare to our current lighttpd webserver. FYI, the apps works just fine with lighttpd which makes it even more puzzling.. Please help? Many thanks in advanced for all of your help to this matter and have a wonderful day.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 247
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready