Reputation: 972
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)
Upvotes: 0
Views: 164
Reputation: 12246
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?
Upvotes: 1