Solved

Im getting 500 Internal Server Error when using .post() jquery

Posted on 2011-09-28
22
372 Views
Last Modified: 2012-05-12
Im trying to use .post()  in a jquery sumbit form
the ur l= handelSpamDb.php

and I get 500 Internal Server Error
            26ms

$("#"+popup_form_id).submit(function(e) {
                         //   alert("Hello world!");
							//fElement.attr('flag','1');
							e.preventDefault();
						//"mark" the input name =flag as spam 
						    $(":hidden[name='flag']","#"+popup_form_id).val("on");
							fElement.toggle();
							//$.ajax(
							alert($(this).serialize() +"tryinggg");
							$.post(url,$(this).serialize());
								
							
					})

Open in new window

0
Comment
Question by:Nura111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 6
  • 3
22 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 36719938
That has to be an error in 'handelSpamDb.php' because jquery does not run on the server.  Do you have an alternate way of testing 'handelSpamDb.php' like a simple HTML form that will POST to it?
0
 

Author Comment

by:Nura111
ID: 36720002
the code in theat file was previuosly in a diffrent location wraped by if isset[formSumbit]
and it was working

Do I still need ro access the variables in $_POST see code
$id = $_POST['id'];

$email = $_POST['email'];



$sql= BaseModel::getSqlObject();

$query = "SELECT * FROM BlackList WHERE email_address = '$email'";	

	     

	if (($result=$sql->Query($query)) === FALSE)

      die(ShowError("Server Query Error"));

$num = $result->num_rows;

	   

	//check if email is not already exist in BlackList

	if ($result->num_rows == 0){

   			 $insert_query = "INSERT INTO BlackList(email_address) VALUES ('$email')";

			 

	 if (($result=$sql->Query($insert_query)) === FALSE)

           	die(ShowError("Server Insert Query Error"));

		}

		

		$insert_query =	"UPDATE ServiceRequests SET spam = 1 WHERE id = '$id'";

		if (($result=$sql->Query($insert_query)) === FALSE)

           	die(ShowError("Server Insert Query Error service"));





			die ("ok");

         

	

		

 

		

		}

Open in new window

0
 

Author Comment

by:Nura111
ID: 36720039
Does it matter who is the referral page?
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:Nura111
ID: 36720076
the fire bug debug is saying the mistake is in       
jquery.js (line 7950)
0
 

Author Comment

by:Nura111
ID: 36720110
Is it ok to gop in the script to $_POST is it suppose to be there after sent it with .post()?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36720144
The Firebug error is a different subject because Firebug can't tell you about server errors, only javascript and DOM.
0
 

Author Comment

by:Nura111
ID: 36720151
Is it ok to go in the refred script to $_POST is it suppose to be there after sent it with .post()?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36720166
I'm not sure I understand.  If you send the data as a POST like you are showing, then it has to be received in the $_POST array.
0
 

Author Comment

by:Nura111
ID: 36720212
Ok so is nyone can help in the server error issue?
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36720309
What is the value of url from the post call? Are you sure it's the file that is handling your post values?
0
 

Author Comment

by:Nura111
ID: 36720318
Do you mean what I wrote in the question    url = handelSpamDb.php

and yes Im sure I attched the code also
0
 

Author Comment

by:Nura111
ID: 36720327
what is the common way im suppose to handle the errors in the jquery submit?
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36720407
What I was asking was if we were sure that the value in url is actually the file we expect the request to be made against. The code shown does not show how the 'url' variable is assigned - so I asked.

.post supports using an .error() function to handle when the post is not returned successfully. It would look something like:

$.post(url,$(this).serialize()).error(function() { alert('post failed'); });

Open in new window


Are there any errors that show up in the webserver logs? If this is apache on linux, it may be in /var/log/https/error_log or something but that would depend on the system configuration.
0
 

Author Comment

by:Nura111
ID: 36720437
Its on vmware there is only one filr in log folder and it doesnt show anything
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36720454
Can you type the page address in the address bar and get it to load without error?
0
 

Author Comment

by:Nura111
ID: 36906041
no its not working is well its cant find it but the php file is there in the public folder like all the other ones that I can get access directly by entering the url
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36906055
Can you check the permissions of the file? Are they the same as the other files that are working?
0
 

Author Comment

by:Nura111
ID: 36906068
yes same pemisiions read and write
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36906134
Same file extension? Like the ones working aren't .php and this one .inc or something, right?

There has to be something different, I'm just taking guesses at what they could possibly be.
0
 

Author Comment

by:Nura111
ID: 36906143
no there are both .php extention
0
 
LVL 11

Assisted Solution

by:MacAnthony
MacAnthony earned 250 total points
ID: 36910123
And there is nothing in either the apache or php error logs?

I'm kind of at a loss for ideas of what could cause this.
0
 

Author Comment

by:Nura111
ID: 36911311
what are the possible location the log file can be?
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PDF Turn Look 7 34
Add Rows on a Table 8 53
JSON help 8 47
Javascript BBCode (Code Provided) Select text, click button, jumps to the bottom 6 15
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question