beginner
beginner

Reputation: 2032

YII2 Submitting form using ajax adds additional word in the URL

The current URL is http://localhost/ncddp/backend/web/sp-bub/update?id=89

In the form, there is a select tag with the values of a province. When a certain province is selected, It will submit using Jquery/Ajax to get the list of municipalities or cities.

here is the code...

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

but I get this 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 this page is not found. Why did it submit to http://localhost/ncddp/backend/web/sp-bub/sub-project/getcities wherein it should be submitted to http://localhost/ncddp/backend/web/sub-project/getcities

Upvotes: 0

Views: 107

Answers (1)

Ivoglent Nguyen
Ivoglent Nguyen

Reputation: 504

Because you used relative path and you are here :

/ncddp/backend/web/sp-bub/

and sub-project/getcities will be subpath Try absolute url like :

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

or relative :

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

Upvotes: 1

Related Questions