Jquery - Ajax Returning Error 500 on Some Posts

Jquery $ajax funtion returns 500 Internal Server Error in C#

Use the .cs file like this,

[WebMethod]
public static List<pageResult> getSelectedData(string search_value)
{}

For ajax calling in aspx you should define the method as Static then only it will working for you.

jQuery - Ajax returning error 500 on some posts

First off, this has nothing to do with jQuery, AJAX, POST, CakePHP, or HTTP headers. The complete error message is "Premature end of script", which means that the PHP process that Apache is using to run the PHP script terminated unexpectedly (i.e., before the PHP process finished its part of the Fast CGI protocol). This generally means that the PHP process crashed or caused a "segmentation fault".

PHP segmentation faults can be difficult to troubleshoot, and they should never happen; PHP should never crash. The reason why it is crashing could be due to a number of things. Maybe it is a simple fix, though.

The first thing that I would do is completely uninstall PHP and install the latest stable version. If you are running PHP 5.3 and Windows, then you should only use the VC6 binaries (the "VC6 x86 Thread Safe" package); the VC9 package will cause PHP to crash when used by Apache. Reinstalling might fix your problem because extension DLLs/SOs of older releases of PHP might still exist in your extensions directory on the live server.

If on Windows and using MySQL, the next thing that I would do is make sure that the MySQL bin directory is in the live server's Path. The reason for doing this is to make sure that libmySQL.dll can be "found" by the OS. You should be able to SSH into the live server, type mysql --help, and see the MySQL CLI client's usage message. Restart Apache if you add the MySQL bin directory to Path.

If both of these suggestions do not solve the problem, then please update your question with answers to the following:

  1. Are you using a web host or does a company IT team manage a server for your use?
  2. If using a web host, are you leasing a dedicated server?
  3. What operating system are you running?
  4. What version of PHP are you using?
  5. What PHP extensions are being loaded?
  6. Do you load a Zend extension?
  7. Do you ever use dl?

UPDATE: With version 5.3.6 and later, the PHP project no longer releases "VC6" installers. The recommendation is to install a build of Apache HTTPD from Apache Lounge and use a "VC9" installer.

jQuery AJAX request to PHP returns error 500

Since you are using these paths like this you will need to modify includes.

You are testing that the methods in project_manager.php from the view file, which gets included in your index file. So, you're likely not running into a path issue there because the path is being referenced from the same place your index file is located.

But, when your ajax tries to read something from ajax/register.php, the file paths are no longer based on the same place as the index file, which is why you should test this file directly.

You'll need to do the following in your register.php file, and likely change around how you handle the other include stuff as well in your other files, since this may not work because you're now referencing files based on the ajax directory.

include_once '../config/config.php';

This will break anything else that references it (the index), but you'll need to do this to get the ajax register php page working temporarily:

include "../classes/project_manager.php";

You can take a look at the following post for ideas about how to handle your includes:

PHP include relative path

And let PHP post errors and warnings to the browser for you, so you can read them instead of seeing that 500 internal server error page.

Showing all errors and warnings

jQuery - AJAX POST Request is giving a 500 Internal Server Error

500 Code means something isn't working on the server-side. I had a similar situation where a different server than my own gave this problem even though it provided all of the information itself and seemed to work well.

I couldn't resolve the 500 error, so eventually just put an always() listener on the call and conditioned 200 and 500 codes along with expected data structure.

since you're not storing the call in a var. you can do it like this:

function commandUpdate(command, action, element) {
$.ajax({
type: "POST",
url: "update/commands.php",
data: {id: window.location.href.split("?id=").slice(1).join("?id="), type: "NA", command: command, action: action, value: document.getElementById(command + "Text").value},
success: function() {
document.getElementById(element).innerHTML = "br> location.reload()
}
statusCode: {
200: function(){
document.getElementById(element).innerHTML = "br> location.reload()
}
500: function(){
document.getElementById(element).innerHTML = "br> location.reload()
}
}
})
}

or chain it:

 $.ajax({
/*options*/
}).always(function(data){
if(data.statusCode === 200 || data.stausCode === 500){
/*Do things with data*/
}

});


Related Topics



Leave a reply



Submit