Posts

Showing posts with the label ajax

Trying to get PHP responce on ajax

Image
Clash Royale CLAN TAG #URR8PPP Trying to get PHP responce on ajax here I am trying to update the MSQL table using jquery , both PHP code and jquery script is written on the same page, the code working fine to update my tables but the response msg is not getting by the ajax so it always shows me the default message "Some problem occurred, please try again.". here is the code: <!-- HTML code to display msg --> <p class="statusMsg_post"></p> <script> $(document).ready(function(){ $('#btn_publish').click( function(){ var obj_post_postID="<?php echo $post_id; ?>"; var publish_post="publish"; $.ajax({ type:'POST', // url:'post_view.php', data:{ "post_status_update":publish_post, "obj_post_status":obj_post_postID, }, success:function(res){ if(res==...

Trouble in consuming API having security?

Image
Clash Royale CLAN TAG #URR8PPP Trouble in consuming API having security? API Document : To access the service, you must pass a valid Authorization: header in every request.Requests that originate from your own server via a script, HTTP proxy, etc. should include a private key, which you should keep secure, as you would a password. The complete Authorization: header with your private key is: Authorization: privateKey ******** Requests that originate from a web browser will be blocked if they include a private key Requests that originate from a web browser should include a public key, not a private key. Public keys do not need to be protected, and can be distributed freely to your users. The complete Authorization: header with your public key is: Authorization: publicKey *************** To make requests with a public key from a web browser, the origin domain must also be whitelisted. We have whitelisted these domains for you: *.****.com API CURL: HTTP GET: /body/{bodyId}/render Renders t...

Fill Selectize optgroup columns with AJAX in Laravel

Image
Clash Royale CLAN TAG #URR8PPP Fill Selectize optgroup columns with AJAX in Laravel I'm trying to assign attributes to product at client-side using Selectize . In Laravel , against Ajax request, I'm returning a JSON object from Controller as shown below: Selectize Laravel Ajax JSON $attribs = AttributeClass::find($request->id)->attributes; $attributes = array(); foreach($attribs as $attrib){ $options = array(); foreach($attrib->options as $opt){ $options = array( 'id' => $opt->id, 'name' => $opt->name ); } $attributes = array( 'id' => $attrib->id, 'name' => $attrib->name, 'options' => $options ); } return response()->json([ 'attributes' => $attributes ]); The JSON output looks something like this: JSON "{"attributes...

How can we populate jsGrid with stored procedure?

Image
Clash Royale CLAN TAG #URR8PPP How can we populate jsGrid with stored procedure? I have to populate jsgrid with result returned by stored procedure. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to post a WebGrid to a Controller using Ajax

Image
Clash Royale CLAN TAG #URR8PPP How to post a WebGrid to a Controller using Ajax I want to post the full WebGrid from my view to my controller using ajax. In this WebGrid I display a table from a database and I want to provide, that the user of this webpage can update the columns (in the database). WebGrid WebGrid My try so far: public JsonResult UpdateTable(GridView model) { // Update Model to db.. string message = "Success"; return Json(message, JsonRequestBehavior.AllowGet); } The GridView model here has always 0 columns. GridView model WebGrid <div id="tableGridDiv"> @grid.GetHtml( tableStyle: "table", columns: cols) </div> Script $('.save-user').on('click', function () { var grid = $("#tableGridDiv").find("table.grid").first(); alert(grid.innerHTML); var jsonGrid = JSON.stringify(grid); //var jsonGrid = $.parseJSON(grid); alert(jsonGrid); $.ajax({ ur...

Knockout JS Fill table with Ajax Request

Image
Clash Royale CLAN TAG #URR8PPP Knockout JS Fill table with Ajax Request I am new to Knockout JS and I have been trying without success to fill a table with the result of an Ajax request. I have followed several tutorials and many a Stack Overflow questions but I am still not getting the results I need. The error that I am getting right now is that my observable array is not defined. Here is my JS code: function FeatureRequest(data) { if(data != null){ // console.log("Feature Request"); // console.log(data); this.title = ko.observable(data.title); this.description = ko.observable(data.description); this.client_id = ko.observable(data.client_id); this.client_priority = ko.observable(data.client_priority); this.product_area_id = ko.observable(data.product_area_id); this.user_id = ko.observable(data.user_id); this.target_date = ko.observable(data.target_date); this.ticket_url = ko.observable(data....

Behat tests: I click on the button and the test is stopping - Ajax request

Image
Clash Royale CLAN TAG #URR8PPP Behat tests: I click on the button and the test is stopping - Ajax request I'm using the Behat testing in my website and I'm trying to click on one of the button and the test is stopping (without response or exception). This button calls to a js function which function make a AJAX request to the PHP code and I think that this is the problem, because the others buttons works good every time. Any ideas? This is the code and the configuration. Scenario Then I click on the "a.next_step" FeatureContext.php /** * @Then /^I click on the "([^"]*)"$/ */ public function iClickOn($element) { $page = $this->getSession()->getPage(); $find_name = $page->find('css', $element); if (!$find_name) { throw new Exception($element . ' could not be found'); } else { $find_name->click(); } } behat.yml #behat.yml default: extensions: DMoreChromeExtensionBehatServiceConta...

modal form not submit using jquery

Image
Clash Royale CLAN TAG #URR8PPP modal form not submit using jquery I was looking for a way to keep my modal form open after submit and I manage to do that but now my problem is the submit form is not submiting the value. Is there somthing wrong with my jQuery? Here is my code: <form class="needs-validation" id="contact-form" action="index13.php" method="post" novalidate> <div class="row" style="margin-left: 300px;"> <label>Date:</label> <span id="date1" name="date"></span> </div> <div class="row" style="margin-left: 300px;"> <label>Time:</label> <span id="clock1" name="time"></span> </div> <div class="md-form form-sm mb-5" style="margin-top: 05px;"> <i class="fa fa-user prefix"></i> ...

How do I convert jQuery AJAX code to vanilla JavaScript? [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP How do I convert jQuery AJAX code to vanilla JavaScript? [duplicate] This question already has an answer here: I have an AJAX script in jQuery that I am trying to convert to vanilla Javascript. I Can't seem to convert this. How would I convert this to vanilla JavaScript? $.ajax({ url: 'csv_data.csv', dataType: 'text', }).done(successFunction); $('body').append(table); This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. That is plain javascript. Do you mean you don't want to use jQuery? – Mark Meyer 1 hour ago fetch(url, request).then(function(respose) { successFunction(response)}) – Egor Egorov 1 hour ago ...

ajax doesn't work in chrome [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP ajax doesn't work in chrome [duplicate] This question already has an answer here: I want to show html files on the same page after the button is clicked. I created 3 buttons and when I click on it the browser loads according page with images. But Chrome shows me an error: jquery.min.js:2 Failed to load file:///C:/Users/Ksena/proj/ajax/tabs/autumn.html: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. send @ jquery.min.js:2 ajax @ jquery.min.js:2 w.fn.load @ jquery.min.js:2 (anonymous) @ index.html:23 dispatch @ jquery.min.js:2 y.handle @ jquery.min.js:2 <div class="container"> <button class="summer">Summer</button> <button class="autumn">Autumn</button> <button class="winter">Winter</button> <div class="output"></div> </div> <script> ...

Send Image with Ajax to database (php) without reloading [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP Send Image with Ajax to database (php) without reloading [duplicate] This question already has an answer here: I create a bootstrap modal popup form to add picture in gallery page, I developed the php & ajax code because i want without page reloading here :- the problem is when I want to send image to database I show this error Notice: Undefined index: photo in .... Notice: Undefined index: photo in .... I can't send image. this's my ajax code $(function() { //twitter bootstrap script $("button#submit").click(function(){ $.ajax({ type: "POST", url: "image.php", data: $('form.contact').serialize(), success: function(msg){ $("#thanks").html(msg) $("#myModal").modal('hide'); }, error: function(){ alert("failure"); } }); }); }); And this's Image.php file include 'db.php'; if(isset($_POST['titre']...

how to dynamically add rows to google pie chart using ajax and jquery

Image
Clash Royale CLAN TAG #URR8PPP how to dynamically add rows to google pie chart using ajax and jquery how do I dynamically add rows to the google pie chart on each time the data is pulled by ajax call? html <div id="piechart" style="width: 900px; height: 500px;"></div> google pie chart google.charts.load("current", {packages: ["corechart"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ]); var options = { 'width': 900, 'height': 500 // pieHole: 0.4, }; var chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data, options); } now instead of I want dynamic ...

displaying text using php echo with innerhtml inside a data-filter

Image
Clash Royale CLAN TAG #URR8PPP displaying text using php echo with innerhtml inside a data-filter Hey guys! I have attempted to inject php instead of text as innerhtml using 'onclick' This script appears in the 'head' of my website. I have a data-filter to display images under categories. 'onclick' the images are displayed. Underneath the images the php as text should appear - a heading for the category and description underneath. If left as straight innerhtml this all works. It is the php echo that doesn't. I really would like this to work so that the heading and description can be managed from the CMS (database). 1[this is an example of the type of image display] http://bootstraplovers.com/assan-kit-v3.7/bootstrap4/website-templates/classic-template/html/folio-mosaic-full.html)< <!-- script for product category and description --> <script> function clearText(){ //clears all TEXT when ALL link clicked ...

add data back to text field

Image
Clash Royale CLAN TAG #URR8PPP add data back to text field I'm trying to populate a <input /> from the database using AJAX, but can only get the data testing in a <textarea> or <span> . <input /> <textarea> <span> My AJAX code $('#part_number').on('change', function() { var part_number = $(this).val(); $.ajax({ url: '<?PHP echo admin_url('admin-ajax.php'); ?>', type: 'post', data: { action: 'description', part_number: part_number }, success: function(data) { $('#description').val( data ); } }); }); My input field <input id="description" value="" /> <input id="description" value="" /> functions.php add_action('wp_ajax_description' , 'description'); //ajax parameter action add_action('wp_ajax_nopriv_description','description'); functio...