YII2 Submitting form using ajax adds additional word in the URL -


the current url http://localhost/ncddp/backend/web/sp-bub/update?id=89

in form, there select tag values of province. when province selected, submit using jquery/ajax list of municipalities or cities.

here code...

$.post('sub-project/getcities',{'prov':prov_code}, function(data)     {        $('#tblspbub-city').html(data);     } 

but response..

remote address:[::1]:80 request url:http://localhost/ncddp/backend/web/sp-bub/sub-project/getcities request method:post status code:404 not found 

i know page not found. why did submit http://localhost/ncddp/backend/web/sp-bub/sub-project/getcities wherein should submitted http://localhost/ncddp/backend/web/sub-project/getcities

because used relative path , here :

/ncddp/backend/web/sp-bub/ 

and sub-project/getcities subpath try absolute url :

http://localhost/ncddp/backend/web/sub-project/getcities 

or relative :

/ncddp/backend/web/sub-project/getcities 

Comments