Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7077611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:26:43+00:00 2026-05-28T06:26:43+00:00

I wrote a simple jQuery function to submit data from a textarea. The script

  • 0

I wrote a simple jQuery function to submit data from a textarea. The script returns the result of the computation.
I get an error saying that recievedData isn’t defined.
When debugging with firebug I can see a response.

Here’s my jQuery function.

$('#submitButton').click(
function(evt){
userCode = $('#answer').val();
$.ajax({
type : 'POST',
url : 'scripts/php/check_answer.php',
data : 'code=' + userCode,
dataType : 'text',
success : alert(recievedData)
});
evt.preventDefault;
});

And this is the php script

<?php

//sample string, to be taken as input from the user program.
$str = $_POST['code'];
//the array with the weights
$patterns = array (
    '/[:space]/' => 0, //whitespaces are free; need to add spaces too
    '/[a-zA-Z]/' => 10, //characters
    '/[0-9]/'   => 500, //digits
    '/[\+\-\/\*\%]/' => 10000, //arithmetic operators
    '/[\<\>]/' => 5000, //relational operators
    '/[\^\~\|\&]/' => 1000 , //bitwise operators
    '/[\=]/' => 250, //assignment operator
    '[\#]' => 100000 //No Macros
);

//default weight for characters not found is set here
$default_weight = 55;
$weight_total = 0;
foreach ($patterns as $pattern => $weight)
{
  $match_found =  preg_match_all ($pattern, $str, $match);
  if( $match_found )
  {
     $weight_total += $weight * $match_found;
  }
  else
  {
    //this part needs to be fixed
     $weight_total += $default_weight;
  }
}

echo $weight_total;

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:26:44+00:00Added an answer on May 28, 2026 at 6:26 am

    Write

    success:function(data){alert(data);}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this on a simple ASP.NET page: jQuery(document).ready(function() { jQuery(form).submit(function() { alert(kikoo); return
I'm learning JQuery and I wrote a simple AJAX external script for my homepage
I have this jQuery simple code: <script type=text/javascript> <!-- jQuery(function(){ jQuery('#old_thumb').click(function(){ $(this).val($(this).attr('title')); $('#sf').val('2'); $('#add_new_event').submit();
I am trying to write a simple piece of Jquery in which the script
I wrote a simple batch file as a PowerShell script, and I am getting
I wrote a simple javascript function to display a progressbar with the help of
I wrote a simple Sinatra app that generate an image using rmagick from some
I have simple form with a textarea and a button, and I submit the
I have a form submit, where it get the values from the form and
I wrote this simple piece of code to prevent a form from being submitted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.