简体   繁体   中英

Drupal: Ajax post getting internal server error

I cannot figure out why the following is giving out internal server error. I can see on console log that I am getting the value, but I can not pass it for some reason.

mav_id = document.getElementById("mav_id");
var teamName  = mav_id.value;


 jQuery.ajax({
    type: "POST",
     url: 'http://xx.xxx.xxx.xxx/sites/all/modules/insert.php',
    dataType: 'json',
    data:  teamName,

    success: function (obj, textstatus) {
                  if( !('error' in obj) ) {
                      yourVariable = obj.result;
                  }
                  else {
                      console.log(obj.error);
                  }
            }
});

PHP

    <?php
    if(isset($_POST['teamName']) or isset($_POST['data'];))
    {
   connector info
        }

      $sql = 'INSERT INTO [mydb].[dbo].[team]
    VALUES (2,3)';
    mssql_query($sql, $link);
    }
    else 
      $sql = 'INSERT INTO INSERT INTO [mydb].[dbo].[team]
    VALUES (0,0)';
    mssql_query($sql, $link);
    ?>

All I get is:

POST http://xx.xxx.xxx.xxx/sites/all/modules/insert.php 500 (Internal Server Error)

That is because of this line (the extra semicolon):

if(isset($_POST['teamName']) or isset($_POST['data'];))

change it to:

if(isset($_POST['teamName']) or isset($_POST['data']))

I'm also not sure why you don't have {} for your else and why you have connector info between the if I'm guessing you don't have that in your actual script?

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