简体   繁体   中英

How to manipulate URL inside ajax call?

I am trying to trigger an ajax call on change of a dropdown menu(at client_script.php). The ajax call will send some values to server_script.php and it will change a div section of the client_script.php. The problem is the server script is kept in a local directory such as blocks/latestgrades/server_script.php. When the ajax call is done the url becomes the address of the server_script.php prepended by

 http://localhost/umoodle 

Which is quite ok, because the server_script/php file location is such. But when I hover around the other pages, the onchange triggeres the ajax call which tries to find the server_script.php on that location but prepended by

http://localhost/umoodle/<something_i_dont_want_here>/

How to alter the url to cut that place I dont want and then do an ajax call with that?

Make sure the ajax url is an absolute url (beginning with a forward slash) so that it is formed from the root instead of relative to the current page. For example: (url: '/umoodle')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM