-1
   <!DOCTYPE html>

<html>

<head> 
<script src="test.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquer‌​y.min.js"></script>
</head>



<body>

<form>
<input type="text" class="form-control" id="consult" placeholder="consult">
<input type="text" class="form-control" id="url" placeholder="url">
<button type="submit" >Send Data </button>
</form>



</body>

</html>

here is my code html updated

$(document).ready(function(){
  console.log("ext loaded")
    $("button").click(function(e){
    e.preventDefault()
    var consult = $("input#consult").val()
    var url = $("input#url").val()
    console.log(consult, url)
    // alert(consult+ url)
        $.ajax({
          type: "POST",
          url:"https://www.jbhired.com/admin/server/submitSearch.php",
          dataType: "jsonp",
          crossDomain: true,
          data : {
            consult: consult, 
            url: url
          },

        })
    });
});

this is js file updated

 {
    "manifest_version": 2,
    "name": "One test",
    "description": "test.",
    "version": "1.0",
    "browser_action": {
        "default_icon": "pic1.png",
        "default_popup": "popup.html",
        "script" : "test.js"
    },

    "content_security_policy": "script-src 'self' 'http://ajax.googleapis.com; object-src 'self'"
}

and this is menifest file

error is

Uncaught ReferenceError: $ is not defined at test.js:4

popup.html:1 Refused to load the script 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquer%E0%B9%82%E2%82%AC%C2%8C%E0%B9%82%E2%82%AC%C2%8By.min.js' because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".

punchh
  • 561
  • 1
  • 4
  • 5

1 Answers1

0
 <html>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>


    <script>
    if (typeof jQuery != 'undefined') {
         alert("I found itttttt");
    }else{
         alert("jquery library not found ");
    }  

    var $ = jQuery;
    $(document).ready(function(){
      console.log("ext loaded")
        $("button").click(function(e){
        e.preventDefault()
        var consult = $("input#consult").val()
        var url = $("input#url").val()
        console.log(consult, url)
        // alert(consult+ url)
            $.ajax({
              type: "POST",
              url:"https://www.jbhired.com/admin/server/submitSearch.php",
              dataType: "jsonp",
              crossDomain: true,
              data : {
                consult: consult, 
                url: url
              },

            })
        });
    });
</script>
<body>
<p>hello</p>
</body>
</html>

I dont know how are you doing this, but I see " I found ittt"

Foo Bar
  • 165
  • 2
  • 14
  • " i found ittt' i write for alert to find my jquery library – punchh Jun 19 '17 at 08:35
  • I know, Im not that noob to javascript. I was stating that in the code you posted there are no bugs, it shows that jquery is present. – Foo Bar Jun 19 '17 at 12:28
  • sorry i dont mean you are noob but i just explain – punchh Jun 20 '17 at 01:56
  • Don´t worry, there is no offense when none is taken ;) Did you solve this question? @punchh – Foo Bar Jun 20 '17 at 06:32
  • i can but still have another error show more haha cause i put a data in my textfield but there show an error jquery-3.2.1.min.js:4 Refused to load the script 'https://www.jbhired.com/admin/server/submitSearch.php?callback=jQuery321003675715372465249_1497940420192&consult=qwsa&url=&_=1497940420193' because it violates the following Content Security Policy directive: "script-src 'self'". like this – punchh Jun 20 '17 at 06:35
  • Refused to load the script 'https://www.jbhired.com/admin/server/submitSearch.php?callback=jQuery32101767394122710031_1497940566629&consult=fefef&url=fefef&_=1497940566630' because it violates the following Content Security Policy directive: "script-src 'self'". – punchh Jun 20 '17 at 06:36
  • BUT read the documentation, please, this is insecure. https://stackoverflow.com/questions/37935657/refused-to-load-the-image-because-it-violates-content-securtiy-policy-cordova – Foo Bar Jun 20 '17 at 06:38