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 8840873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:34:10+00:00 2026-06-14T10:34:10+00:00

Everything is going well with my ajax code when passing variables, lets say hello

  • 0

Everything is going well with my ajax code when passing variables, lets say “hello world” but when passing a variable containing such as “hello world http//www.facebook.com” leads to many problems actually.

Actually its the variable “new_textarea” that I am having problem with.
To clarify things out say,

var new_textarea = "hello world"; //successfully saves it to database

but when

var new_textarea = "http://www.facebook.com" // will lead to problems

This is my ajax code:

$.ajax({
url: '/learns/quickpostcomment/'+user_discussion_id+'/'+user_id+'/'+new_textarea+'/'+parent_id,
success: function(data){
}});

And this is my cakephp:

public function quickpostcomment()
{
    $post = $this->params['pass'];
    $this->ClassroomComment->create();
    $this->ClassroomComment->set('classroom_id', $post[0]);
    $this->ClassroomComment->set('user_id', $post[1]);
    $this->ClassroomComment->set('comment', $post[2]);
    $this->ClassroomComment->set('parent_id', $post[3]);
    $this->ClassroomComment->save();
    die;
}

So far all that I inspected is that whats triggering the problem is the “/” or slashes on the variables when variables contain a url.

Is there any way I can pass a variable to my ajax containing slashes or url?
I need help badly 🙁

  • 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-06-14T10:34:11+00:00Added an answer on June 14, 2026 at 10:34 am

    I think you should send a POST request with Ajax instead of a GET. If you build the posted data correctly, you could event get them in your action as you get data from standard Cake forms.

    jQuery.ajax({   
        url     : "<?php echo Router::url(array('controller' => 'learns', 'action' => 'quickpostcomment'), true); ?>,
        type    : "POST",
        cache   : false,
        data    : "data[ClassroomComment][user_discussion_id]=" + user_discussion_id + "&data[ClassroomComment][user_id]=" + user_id + "&data[ClassroomComment][new_textarea]=" + new_textarea + "&data[ClassroomComment][parent_id]=" + parent_id,
        success : function(data){
    
        }
    };
    

    The posted data would then be available in you controller in:

    $this->request->data['ClassroomComment']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our company's ecommerce shop uses magento application. Everything is going well but there is
So I've set up a nanoc site and everything is going well, the only
I am deserializing yahoo contacts api's json response everything is going good but I
I'm creating a little game using Three.js and everything is going well apart from
I'm making a typing tutor program using javascript. Everything is going well except that
I am busy with a nice slider for videos and everything is going well
I'm reasonably new to NHibernate and everything has been going pretty well so far
I've been implementing OpenFeint today and everything was going well until I noticed what
I'm using Symfony2 and CraueFormFlowBundle to create a multi-step form. Everything is going well
I am learning about LINQ-to-SQL and everything was going well until something strange happened:

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.