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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:58:29+00:00 2026-06-16T01:58:29+00:00

I am trying to sending an ajax request from javascript to get data from

  • 0

I am trying to sending an ajax request from javascript to get data from the salesforce using the following code, but I keep getting Error:0 message. It seems my request is not sending properly. I do not know what is wrong with my code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
    var $j = jQuery.noConflict();
    $j(function(){  
        var url = 'https://myorg-developeredition.na14.force.com/services/apexrest/clsapi';
        $j.ajax({
            url: url,
            type: 'POST',
            success : function() { 
                alert('Hello'); 
            },
            error : function(jqXHR, textStatus, errorThrown) {
                alert('Error: ' + jqXHR.status);
            },                
        });
    });
</script>

But when I type the same url in the browser, I got the response from the salesforce. It shows

<response>myresponse</response>

Thanks

  • 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-16T01:58:33+00:00Added an answer on June 16, 2026 at 1:58 am

    You are sending a cross domain request which your browser is preventing due to the Same Origin Policy.

    To send a cross domain request, you must use jsonp.

    var url = 'https://myorg-developeredition.na14.force.com/services/apexrest/clsapi';
    $j.ajax({
        url: url,
        type: 'POST',
        dataType: 'jsonp', 
        success : function() { 
            alert('Hello'); 
        },
        error : function(jqXHR, textStatus, errorThrown) {
            alert('Error: '+jqXHR.status);
        } // <-- remove the trailing comma you had here
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ajax request in my javascript that is sending data to a
I am new to node.js and I am trying sending data from AJAX to
I'm trying to send an ajax request using jquery. From the tutorial, I try
I am trying to receive a json object back from php after sending data
Am trying to implement scraping using nodejs. Am sending request to a particular url
I am trying to understand how to use an ajax request when sending the
I'm trying to upload a file using AJAX, process data in the file and
I am trying to send data to my controller from an ajax function that
I'm trying to do an XMLHttpRequest from a local file (file://) using JQuery.ajax to
I'm making ajax POST request from javascript function: function UpdateMetrics() { $.ajax({ type: POST,

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.