Support » Fixing WordPress » Post 404 not found, Jquery error

  • Resolved 420DankStank

    (@420dankstank)


    Having some troubles. I have a custom plugin. In my dashboard, I select the plugin admin page. I do a search for a person, and it should load that person for me to edit. However, I am just getting a loading spinner. No results pop up. Chrome Development tools says I am getting an error:

    POST /loadpatient.php 404 (Not Found)

    I click the down arrow to get more info on the error and it shows:

    send jquery.min.js:2197
    b.extend.ajax jquery.min.js:2062
    (anonymous function) script.js:44
    b.event.dispatch jquery.min.js:705
    v.handle

    I click the one that says ‘anonymous function’ and it shows the part of the code from the php file:

    $j(“#loadpatient-form”).submit(function() {
    $j(“#loading_spinner”).show();
    var str = $j(this).serialize();
    $j.ajax({
    type: “POST”,
    url: plugin_location + ‘loadpatient.php’,
    data: str,
    success: function(msg) {
    $j(“#note”).ajaxComplete(function(event, request, settings)
    {
    $j(“#loading_spinner”).hide();
    $j(this).html(msg);

    $j(“#editpatient-form”).submit(function() {
    $j(“#loading_spinner”).show();
    var str = $j(this).serialize();
    $j.ajax({
    type: “POST”,
    url: plugin_location + ‘editpatient.php’,
    data: str,
    success: function(msg) {
    $j(“#note”).ajaxComplete(function(event, request, settings)
    {
    $j(“#loading_spinner”).hide();
    $j(this).html(msg);
    });
    }
    });
    return false;
    });

    The highlighted part when I click the ‘anonymous function’ script is just

    $j.ajax({

    Please help me figure out the error so that I can pull up and edit the people in my database!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You’re attempting to post an ajax call to
    url: plugin_location + ‘editpatient.php’

    If it’s trying to hit that at the root, then you don’t have plugin_location defined.

    There are a few ways to solve this:
    Define plugin_location
    var my_loc = ‘/wp-content/plugins/(name of plugin)’;
    url: plugin_location + my_loc + ‘editpatient.php’,`

    You can also take out those vars completely.
    url: '/wp-content/plugins/(name of plugin)/editpatient.php'

    I suppose that is a little confusing. It looks like I put two call functions up there. It is just the first. plugin_location = ‘loadpationt.php’,:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. Not the blockquote. ]

    $j("#loadpatient-form").submit(function() {
    $j("#loading_spinner").show();
    var str = $j(this).serialize();
    $j.ajax({
    type: "POST",
    url: plugin_location + 'loadpatient.php',
    data: str,
    success: function(msg) {
    $j("#note").ajaxComplete(function(event, request, settings)
    {
    $j("#loading_spinner").hide();
    $j(this).html(msg);

    * plugin_location + ‘loadpatient.php’, *

    The root location is defined in another php file.

    The root location is defined in another php file.

    But this is javascript. You can’t reference variables which are on a server-side processor (PHP) against a client side processor (javascript).

    I don’t understand. It has worked for the past year. Here is the whole loadpatient.php file: http://pastebin.com/K4N6fkMV

    Here is the Javascript file: http://pastebin.com/9892EY9T

    I don’t know what happened. I just uploaded the plugin folder again and overwrote everything. It’s working again.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Post 404 not found, Jquery error’ is closed to new replies.