WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post 404 not found, Jquery error (9 posts)

  1. 420DankStank
    Member
    Posted 1 year ago #

    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!

  2. jholder83864
    Member
    Posted 1 year ago #

    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'

  3. 420DankStank
    Member
    Posted 1 year ago #

    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);
  4. 420DankStank
    Member
    Posted 1 year ago #

    * plugin_location + 'loadpatient.php', *

  5. 420DankStank
    Member
    Posted 1 year ago #

    The root location is defined in another php file.

  6. jholder83864
    Member
    Posted 1 year ago #

    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).

  7. 420DankStank
    Member
    Posted 1 year ago #

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

  8. 420DankStank
    Member
    Posted 1 year ago #

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

  9. 420DankStank
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic