Welcome Guest, Not a member yet? Register   Sign In
URL limitation?
#1

Hello,

I have weird problem. 

I have "Ajax.php" controller for handling ajax requests. 

Some URL not working for me and I don't know why.

Code:
$.ajax({
  url: ajaxurl + 'add_combined_booking',
...

This will call /ajax/add_combined_booking method (POST). This works fine.


Code:
$.ajax({
  url: ajaxurl + 'delete_combined_booking',
...

This is not working. 

Difference is in method - "add_combined_booking" works but "delete_combined_booking" not working. 

Please, can somebody tell me why? Is there some limitation in URL method length?
Reply
#2

Code:
error: function (xhr, ajaxOptions, thrownError) {
   alert(xhr.status);
   alert(thrownError);
}

Use the above to find out what's wrong.
Simpler is always better
Reply
#3

Thanx, but there are no errors in my ajax request. Even if I access url directly: /ajax/delete_combined_booking there are no error, no errors in log, no error 500, nothing. Even no error in webserver error log.
Reply
#4

There's no built-in limits on URL length, so it's not that.

Is your route setup correctly to recognize the other URL? Does the controller method exist to match up with it? Hard to say why it's not working without additional details.
Reply
#5

URL length is not the problem. The HTTP protocol does not define any limit on the length. Some browsers may implement a limit, but those tend to be around the 2000 mark.

The problem is most likely either the URL is not found or the function isn't returning a useable value. I would expect the first case to produce an ajax error.

Have you used your browser's "web developer" tool to check that the delete method is actually reached? If it is reached, then what, if anything, it does it send in reply? You might want to comment out the code for the desired work and just echo back a string. Use the js console to see if that string is the reply.
Reply
#6

(This post was last modified: 02-11-2020, 04:59 PM by tgix.)

As pointed out - check the developer tools in your browser. CORS is what comes to my mind and possibly what HTTP method is used for the delete request.
I have just completed a project using CI 4.0-rc3 heavily using Ajax-based API with manually routing setup and it works like a charm. You need to take care setting up all the routes, but such problems are easy to find using the browser's developer tools.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB