json – jquery with .getJSON – Education Career Blog

I have 2 forms that share a submit button

("#sbtBtn").click(function() {
          if($("inputname=license_code").val()) {      //check if #retUser has a value
          } else if ($("inputname=referred_by_text").val() || $("inputname=broker_text").val() || $("inputname=email1").val()) {


for “#formOne” I am trying to use jquery’s getJSON function to use a script cross domain, its not working.

            errorElement: "em",
            errorPlacement: function(error, element) {
                error.appendTo( element.parent("li"));
            submitHandler: function(form) {
                var dataString = $(form).serialize();
                $.getJSON("http://www.domain.com/sugar/NT7Lead2.php?data=" + escape($(this).serialize()) + "&callback=?", function(data) {
            return false;
            rules: {
                    license_code: {
                    minlength: 3,
                    maxlength: 39

            messages: {
                license_code: {
                    minlength: "Your License be at Least 3 Characters Including Dashes",
                    maxlength: "Your License Key Cannot Be More Than 39 Characters Including Dashes"

When I view in firebug, the data is being returned from the script but its not being added to “#results”. Is there anything obviously wrong here? Also do I need to include the script in the form action since its in the JSON function? here’s the html

<div class="purchaseFormContain" id="currentUser">
                    <div class="purchaseTH form" id="formOneTH"><h3>Current Users</h3></div>
                    <form method="post" name="formOne" id="formOne">
                        <ul class="features">
                            <li><label for="license_code">Enter Your License Key Here</label></li>
                            <li><input type="text" name="license_code" /></li>
                    <div class="clear"></div>
                    <div id="results"></div>
                <!--/retUser purchaseFormContain --></div>

pls help! thx


Beyond JSONP if you have any experience with server-side languages you could pretty easily create a little app locally that fetches the response for you.

e.g. in Java you have a servlet that takes your the desired parameters, the servlet makes the request and then returns the response.


“You have to see if the site in question supports JSONP” – see Cross domain ajax response failing.


Try getting a sample of the response. It should be JSON. Try to check how you are accessing to the response. I had some problems with that too. Also, it’s a great idea use a server side script. If you use php, try with cURL. It’s easy

Leave a Comment