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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:42:38+00:00 2026-06-17T18:42:38+00:00

I want to rewrite this jQuery Ajax Request which is not working well with

  • 0

I want to rewrite this jQuery Ajax Request which is not working well with cakePHP with a code block in my cakePHP view using JsHelper.
So far, I’ve setup everything( included the helper in my controller, written the buffer in my Layout, included my library(jQuery) ), but I dont know how to rewrite this:

         $.ajax
            ({
                url: 'clients/loadJsonMarkers',
                accepts: 'json',
                type: 'POST',
                data: postData,
                dataType: 'json',
                error: function(xhr,status,err){
                    alert("DEBUG: status"+status+" \nError:"+err);
                },  
                success: function(transport)
                {   

                    var markers = new Array();

                    for(var i in transport.clients)
                    {
                        var latlng = transport.clients[i].Client.geoloc.replace("(", "");
                        latlng = latlng.replace(")", "");
                        latlng = latlng.split(',');

                        //console.debug(latlng);
                        markers.push(new google.maps.LatLng(parseFloat(latlng[0]),parseFloat(latlng[1])));
                    }

                    loadMap(markers);

                }
            });

What I’ve achieved to write so far was this:

    $this->Js->get('document');
    $this->Js->event('load',
            $this->Js->request(
                array('action' => 'loadJsonMarkers'),
                array('assync'=>TRUE, 'type'=>'json', 'method'=>'POST', 'data'=>$_POST)
                ),
            array('success'=>$this->Html->scriptBlock("
                    function(transport)
                    {   
                        var markers = new Array();

                        for(var i in transport.clients)
                        {
                            var latlng = transport.clients[i].Client.geoloc.replace('(', '');
                            latlng = latlng.replace('(', '');
                            latlng = latlng.split(',');

                            //console.debug(latlng);
                            markers.push(new google.maps.LatLng(parseFloat(latlng[0]),parseFloat(latlng[1])));
                        }

                        loadMap(markers);

                    }"
            ))
    );

But I feel like something is missing and I don’t know if I should use this selector(document).

  • 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-17T18:42:39+00:00Added an answer on June 17, 2026 at 6:42 pm

    Since Cake buffers everything and places it in a $(document).ready() function, all you should need to do is add it to the buffer.

    $request = $this->Js->request(
      array('action' => 'loadJsonMarkers'),
      array(
        'async' => true, 
        'type' => 'json', 
        'method' => 'POST', 
        'data' => $_POST,
        'wrapCallbacks' => false,
        'success' => "function(transport) {
          var markers = new Array();
    
          for(var i in transport.clients) {
            var latlng = transport.clients[i].Client.geoloc.replace('(', '');
            latlng = latlng.replace('(', '');
            latlng = latlng.split(',');
    
            markers.push(new google.maps.LatLng(parseFloat(latlng[0]),parseFloat(latlng[1])));
          }
          loadMap(markers);
        }"
      )  
    );
    $this->Js->buffer($request);
    

    Make sure you’re writing the buffer in your layout.

    However, since you’ve already got the pure JS writting you should probably just buffer that, since the JsHelper will likely be removed in CakePHP 3.0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to rewrite core/adminthtml/block/widget/tabs.php class which is a super class for core/adminhtml/block/sales/order/view/tabs.php class.
I want to rewrite this line without using jQuery so it can be applied
I want to rewrite this xslt piece in XSLT 1.0, which does not support
I want to rewrite http://website.com/?slug=product_info.php&products_id=32 to http://website.com/product_info/32 and I use this code, add_filter('rewrite_rules_array','wp_insertMyRewriteRules'); add_filter('query_vars','wp_insertMyRewriteQueryVars');
I want to do Url rewrite in Tomcat using UrlRewriteFilter This is the rule
want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
I've been trying to get this really simple example of using AJAX with JQuery
I want to rewrite this, maybe using predicates, or Lambda, how can I do
I want to rewrite this code without so many else's, but still keep it
I have this URL example.com/photo?people I want to rewrite this URL in the form

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.